using System.IO;
using DevExpress.XtraEditors;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraBars;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Mask;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraTab;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
//using System.Data.OleDb.OleDbCommandBuilder;
//using System.Data.Common.DbCommandBuilder;//JMR -- DEV -- commented out
using System.Data.Common;//JMR -- DEV -- added
using System.Threading;
//using System.Object;//JMR -- DEV -- commented out
//using System;//JMR -- DEV -- added
//using System.MarshalByRefObject;//JMR -- DEV -- commented out
//using System.ComponentModel.Component;//JMR -- DEV -- commented out
//using System.ComponentModel;//JMR -- DEV -- added
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using System.Linq;//JMR used for source.Count()

namespace ePlanSysOman
{
    public partial class frmOps
    {
        public static frmOps newfrmOps1 = new frmOps();//JMR

        #region Declare Adapters for frmOps ,dsDrawings
        public  bool IsElectrical = false;
        public bool isMKPL = false;
        public string newqty;
        public string oldqty;
        public OleDbDataAdapter daAssemply;
        public OleDbDataAdapter daCountry;
        public OleDbDataAdapter daDrawings;
        public OleDbDataAdapter daEffectivities;
        public OleDbDataAdapter daGeneral;
        public OleDbDataAdapter daNotes;
        public OleDbDataAdapter daPartsConsumables;
        public OleDbDataAdapter daPlano;
        public OleDbDataAdapter daRevision;
        public OleDbDataAdapter daSimpleAssemply;
        public OleDbDataAdapter daSteps;
        public OleDbDataAdapter daTools;
        public OleDbDataAdapter daTransferAssembly;
        public OleDbDataAdapter daTransferBackShop;
        public OleDbDataAdapter daTransferCont;
        public OleDbDataAdapter daTransferDrawings;
        public OleDbDataAdapter daTransferEffectivities;
        public OleDbDataAdapter daTransferGeneral;
        public OleDbDataAdapter daTransferMisc;
        public OleDbDataAdapter daTransferNotes;
        public OleDbDataAdapter daTransferPlano;
        public OleDbDataAdapter daTransferRefDes;
        public OleDbDataAdapter daTransferRefDesComp;
        public OleDbDataAdapter daTransferRevision;
        public OleDbDataAdapter daTransferRoute;
        public OleDbDataAdapter daTransferSelHarness;
        public OleDbDataAdapter daTransferTemplate;
        public OleDbDataAdapter daTransferTools;
        public OleDbDataAdapter daTransferWires;
        public OleDbDataAdapter daTransferWiresAdd;
        public OleDbDataAdapter daTransferWiresBackshell;
        public OleDbDataAdapter daTransferWiresRemove;
        public OleDbDataAdapter daTransferWiresRevise;
        private string PlanNumber;

        #endregion
        private void ExportToExcel(System.Data.DataTable objDT, System.Data.DataTable objDT2, System.Data.DataTable objDT3)
        {

            //object Excel = CreateObject("Excel.Application");
            //object Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));//JMR replaced above line 'quick and dirty way'
            Microsoft.Office.Interop.Excel._Application Excel = new Microsoft.Office.Interop.Excel.Application();//JMR -- third attempt
            string strFilename;
            int intCol;
            int intRow;
            string strPath = "c:\\";
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = "Desktop";
            dlg.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx|(Save as xls for Office 2003)|*.xls|(Save as xml File for Sap)|*.xml|All files (*.*)|*.*";
            try
            {
                dlg.FileName = ("MKPL FOR  " + txtDescription.Text);
            }
            catch (Exception ex)
            {
                dlg.FileName = "MKPL";
            }
            if (Excel == null)
            {
                MessageBox.Show("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", "ERROR");//JMR
                return;
            }
            try
            {
                // ERROR: Not supported in C#: WithStatement
                Excel.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\eplansys.pln");
                Excel.Worksheets[2].Select();
                if(txtDescription.Text.Contains("(H16"))
                {                    
                    Excel.Cells[1, 1].value = this.txtDescription.Text.Substring(0, txtDescription.Text.IndexOf("(H16")).Trim();
                }else
                {
                    Excel.Cells[1, 1].value = this.txtDescription.Text;
                }
                //'.cells(1, 1).value = "Heading" 'Heading of the excel file
                Excel.Cells[1, 1].EntireRow.Font.Bold = true;
                Excel.Cells[1, 1].EntireRow.Font.Size = 13;
                Excel.Cells[1, 1].Interior.color = Color.FromArgb(196, 215, 155);
                int intI = 1;
                for (intCol = 0; intCol <= objDT.Columns.Count - 1; intCol++)
                {
                    Excel.Cells[3, intI].value = objDT.Columns[intCol].ColumnName;
                    Excel.Cells[3, intI].EntireRow.Font.Bold = true;
                    Excel.Cells[3, intI].EntireRow.Font.Size = 12;
                    Excel.Cells[3, intI].Interior.color = Color.FromArgb(191, 191, 191);
                    intI += 1;
                }
                intI = 4;
                int intK = 1;
                for(intCol = 0; intCol <= objDT.Columns.Count - 1; intCol++)
                {
                    intI = 4;
                    for(intRow = 0; intRow <= objDT.Rows.Count - 1; intRow++)
                    {
                        Excel.Cells[intI, intK].Value = objDT.Rows[intRow].ItemArray[intCol];                      
                        intI += 1;
                    }
                    intK += 1;
                }

                //if(Mid(strPath, strPath.Length, 1) != "\\")
                //{
                //
                //}

                if (strPath.Substring(strPath.Length - 1, 1) != "\\")
                {
                    strPath = strPath + "\\";
                }

                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    if(dlg.FilterIndex == 3)
                    {
                        DataSet SAPXML = new DataSet();
                        SAPXML.Tables.Add("PARTS");
                        SAPXML.Tables.Add("WIRES");
                        SAPXML.Tables["PARTS"].Merge(objDT);
                        SAPXML.Tables["WIRES"].Merge(objDT2);
                        SAPXML.WriteXml(dlg.FileName);
                        ModuleWaitDialog.newModule2.CloseWaitDialog();
                        MessageBox.Show("File saved as : " + System.Environment.NewLine + dlg.FileName);
                        return;
                    }
                     strFilename = dlg.FileName;
                    //'strFilename = strPath & "Excel2.xlsx";
                    Excel.ActiveCell.Worksheet.SaveAs(strFilename);
                    Excel.Workbooks.Open(strFilename);
                    Excel.Visible = true;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel);
                }

                Excel = null;
                // MsgBox("Data's are exported to Excel Succesfully in '" & strFilename & "'", MsgBoxStyle.Information)
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);//JMR
            }
            // The excel is created and opened for insert value. We must close this excel using this system
        }

        
        //
        #region Form Events

        private void  // ERROR: Handles clauses are not supported in C#
    frmOps_Activated(object sender, System.EventArgs e)
        {
            Module1.newModule.assPlanNumber = PlanNumber;

        }

        private void  // ERROR: Handles clauses are not supported in C#
    frmOps_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
        {

            bdGeneralOps.EndEdit();
            try
            {
                daGeneral.AcceptChangesDuringUpdate = true;
                daGeneral.Update(dsdrawings, "tblGeneral");
            }
            catch (Exception ex)
            {

            }
            try
            {
                daSteps.AcceptChangesDuringUpdate = true;
                daSteps.Update(dsdrawings, "tblTemplate");
            }
            catch (Exception ex)
            {

            }
            try
            {
                daRevision.AcceptChangesDuringUpdate = true;
                daRevision.Update(dsdrawings, "pdfWires");

            }
            catch (Exception ex)
            {

            }
            try
            {
                daNotes.AcceptChangesDuringUpdate = true;
                daNotes.Update(dsdrawings, "tblNotes");

            }
            catch (Exception ex)
            {

            }
            try
            {
                daAssemply.AcceptChangesDuringUpdate = true;
                daAssemply.Update(dsdrawings, "tblAssembly");
            }
            catch (Exception ex)
            {

            }
            try
            {
                daEffectivities.AcceptChangesDuringUpdate = true;
                daEffectivities.Update(dsdrawings, "tblEffectivities");
            }
            catch (Exception ex)
            {

            }
            try
            {
                daTools.AcceptChangesDuringUpdate = true;
                daTools.Update(dsdrawings, "tblTools");
            }
            catch (Exception ex)
            {

            }

            Module1.newModule.IsLoading = false;
            Module1.newModule.opsisopened = false;
        }
        //


        private void Grid_DataNavigator1_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
        {
            if ((e.Button.ButtonType == NavigatorButtonType.Append))
            {
                Module1.newModule.AddRow(this.viewDrawings);
            }
            DataSet aset = new DataSet();
            clsData data = new clsData();
            DialogResult ans;

            if ((e.Button.ButtonType == NavigatorButtonType.Remove))
            {
                ans = XtraMessageBox.Show("Do you want to delete the current row?", "Confirm deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (ans == DialogResult.No)
                {
                }
                else
                {
                    if (this.viewDrawings.IsFocusedView)
                    {
                        string str = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgPartnumber"));
                        string str6 = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgTypever"));
                        string str4 = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgFrom"));
                        string str5 = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgThru"));
                        int length = str.Length;
                        if ((length >= 9))
                        {
                            length = (length - 5);
                            str = str.Substring(length, 5);
                            aset = data.getData(string.Concat(new string[] {
                "select comment FROM TBLECN WHERE TYPEVER ='",
                str6,
                "' and fr0m ='",
                str4.PadLeft(4, '0'),
                "' and thru ='",
                str5.PadLeft(4, '0'),
                "' and ecn = '",
                str,
                "'"
              }));
                            if ((aset.Tables[0].Rows.Count != 0))
                            {
                                Module1.newModule.ecnComment = Conversions.ToString(aset.Tables[0].Rows[0]["COMMENT"]);
                                string str3 = ("Started Pl/c " + Module1.newModule.STRPLANO);
                                if (!Module1.newModule.ecnComment.Contains(str3))
                                {
                                    str3 = ("Finished Pl/c " + Module1.newModule.STRPLANO);
                                }
                                string newValue = "";
                                Module1.newModule.ecnComment = Module1.newModule.ecnComment.Replace(str3, newValue);
                                data.ExecuteSQL(string.Concat(new string[] {
                  "UPDATE tblEcn set  comment ='",
                  Module1.newModule.ecnComment,
                  " 'where comment ='",
                  str3,
                  "' and TYPEVER ='",
                  str6,
                  "' and fr0m ='",
                  str4.PadLeft(4, '0'),
                  "' and thru ='",
                  str5.PadLeft(4, '0'),
                  "' and ECN = '",
                  str,
                  "'"
                }));
                            }
                        }
                    }
                }

            }
        }


        private void  // ERROR: Handles clauses are not supported in C#
    frmOps_Load(System.Object sender, System.EventArgs e)
        {
            this.PlanNumber = Module1.newModule.plnumber;
            clsData data = new clsData();
            DataSet aset = new DataSet();
            Module1.newModule.IsLoading = true;
            CheckEdit2.Properties.ValueChecked = 2.ToString();//JMR -- look at -- changed (string) to ToString()
            CheckEdit2.Properties.ValueGrayed = 1.ToString();//JMR -- look at -- changed (string) to ToString()
            CheckEdit2.Properties.ValueUnchecked = (string)"-";
            this.gridDrawings.EmbeddedNavigator.ButtonClick += Grid_DataNavigator1_ButtonClick;
            switch (Module1.newModule.AreaNo)
            {
                case 12:
                    this.Text = "INDUCTION - OPS";
                    break; // TODO: might not be correct. Was : Exit Select

                case 14:
                    this.Text = "INDUCTION-MISC";
                    break; // TODO: might not be correct. Was : Exit Select

                case 20:
                    this.Text = "REMOVE - SHEETMETALS";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x16:
                    this.Text = "REMOVE - APG";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x18:
                    this.Text = "REMOVE - ELECTRICAL";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x1a:
                    this.Text = "REMOVE - MISC";
                    break; // TODO: might not be correct. Was : Exit Select

                case 40:
                    this.Text = "REWORK - SHEETMETALS";
                    break; // TODO: might not be correct. Was : Exit Select

                case 60:
                    this.Text = "REWORK - APG";
                    break; // TODO: might not be correct. Was : Exit Select

                case 70:
                    this.Text = "REWORK - MISC";
                    break; // TODO: might not be correct. Was : Exit Select

                case 80:
                    this.Text = "POST MOD.- ELECTRICAL";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x52:
                    this.Text = "POST MOD.- APG";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x54:
                    this.Text = "POST MOD.- OPS";
                    break; // TODO: might not be correct. Was : Exit Select

                case 0x56:
                    this.Text = "PREFLIGHT INSPECTION";
                    break; // TODO: might not be correct. Was : Exit Select

                default:
                    this.Text = Module1.newModule.CardNumber;
                    break; // TODO: might not be correct. Was : Exit Select

            }
            this.Text = Module1.newModule.STRPLANO;
            Module1.newModule.Createadapter(this.dsdrawings, "tblTypeVer", ("cId =" + Conversions.ToString(Module1.newModule.CountryId)), ref this.daCountry);
            Module1.newModule.Createadapter(this.dsdrawings, "pdfWires", ("TERM = '" + this.PlanNumber + "'"), ref this.daRevision);
            int num4 = (this.dsdrawings.Tables["tblTypeVer"].Rows.Count - 1);
            int i = 0;
            while ((i <= num4))
            {
                this.rpTVSteps.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.rpTvTools.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.rpTVdrawing.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.rpTvParts.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.RepositoryItemComboBox8.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.rpGenTV.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                this.rpTVRev.Items.Add(RuntimeHelpers.GetObjectValue(this.dsdrawings.Tables["tblTypeVer"].Rows[i]["TYPE/VER"]));
                i += 1;
            }
            Module1.newModule.Createadapter(this.dsdrawings, "tblEffectivities", ("efPlId = '" + this.PlanNumber + "'"), ref this.daEffectivities);
            try
            {
                Module1.newModule.TypeVer = Conversions.ToString(dsdrawings.Tables["tblEffectivities"].Rows[0]["efTypeVer"]);
                Module1.newModule.FRMO = Conversions.ToInteger(dsdrawings.Tables["tblEffectivities"].Rows[0]["efFrom"]);
                Module1.newModule.THRU = Conversions.ToInteger(dsdrawings.Tables["tblEffectivities"].Rows[0]["efThru"]);
            }
            catch (Exception ex)
            {

            }
            if (Module1.newModule.TypeVer == "")
            {
                Module1.newModule.TypeVer = "999";
                Module1.newModule.FRMO = 1;
                Module1.newModule.THRU = 999;
            }
            Module1.newModule.Createadapter(this.dsdrawings, "tblNotes", ("plNotesId = '" + this.PlanNumber + "'"), ref this.daNotes);
            Module1.newModule.Createadapter(this.dsdrawings, "tblAssembly", ("prtPlId = '" + this.PlanNumber + "' and prtEcp <> 'simple'"), ref this.daAssemply);
            Module1.newModule.Createadapter(this.dsdrawings, "tblGeneral", ("genPlId = '" + this.PlanNumber + "'"), ref this.daGeneral);
            Module1.newModule.Createadapter(this.dsdrawings, "tbldrawings", ("DWGPLID ='" + this.PlanNumber + "'"), ref this.daDrawings);
            Module1.newModule.Createadapter(this.dsdrawings, "tblTools", ("tlPLID ='" + this.PlanNumber + "'"), ref this.daTools);
            Module1.newModule.Createadapter(this.dsdrawings, "tblTemplate", ("tmpPLID ='" + this.PlanNumber + "'"), ref this.daSteps);
            //aset = data.getData(("select * from tblAssembly where prtPlid ='" & Me.PlanNumber & "' and prtEcp ='simple'"))
            // Me.gridSimple.DataSource = aset.Tables.Item(0)
            string text = frmMain.start.cmbProgram.Text;
            if (Module1.newModule.excist)
            {
                Module1.newModule.excist = false;
            }
            else
            {
                this.dsdrawings.Tables[3].Rows.Add(new object[] {
          this.PlanNumber,
          text,
          Module1.newModule.STRPLANO
        });
                DataSet dataSource = (DataSet)this.bdGeneralOps.DataSource;
                DataRow row = dataSource.Tables["tblGeneral"].Rows[this.bdGeneralOps.Position];
                if (((Module1.newModule.TITLE == null) | (Module1.newModule.TITLE == "")))
                {
                    row["genDescription"] = "Please fill Description!";
                }
                else
                {
                    row["genDescription"] = Module1.newModule.TITLE;
                }
                row["genTeam"] = Module1.newModule.TEAM;
            }
            clsData data2 = new clsData();
            DataSet set2 = data2.getData(("SELECT * FROM TBLEFFECTIVITIES WHERE EFFROM <>'0' AND EFTHRU <>'0' AND EFPLID = '" + this.PlanNumber + "'"));
            if ((set2.Tables[0].Rows.Count != 0))
            {
                string str2 = "";//JMR -- nulled it
                int num5 = (set2.Tables[0].Rows.Count - 1);
                int j = 0;
                //JMR -- Look at -- is this an infinite loop?
                while ((j <= num5))
                {
                    string str = Conversions.ToString(set2.Tables[0].Rows[j]["efFrom"]);
                    string str5 = Conversions.ToString(set2.Tables[0].Rows[j]["efTypeVer"]);
                    string str6 = Conversions.ToString(set2.Tables[0].Rows[j]["efThru"]);
                    string str3 = string.Concat(new string[] {
            str5,
            "-",
            str,
            "-",
            str6
          });
                    if ((j == 0))
                    {
                        str2 = str3;
                    }
                    else
                    {
                        str2 = (str2 + "," + str3);
                    }
                    j += 1;
                }
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE TBLGENERAL SET GENTYPEVER ='",
          str2,
          "' WHERE GENPLID ='",
          this.PlanNumber,
          "'"
        }));
                this.lblTypeVer.Text = ("TYPE VER: " + str2);
            }
            //aset = data.getData("SELECT * FROM TBLNOTES  WHERE PLNOTESID = '0'")
            //Me.GridControl1.DataSource = aset.Tables.Item(0)
            //Me.GridControl1.Refresh()
            try
            {
                if (CheckEdit2.EditValue != "2" | object.ReferenceEquals(CheckEdit2.EditValue, DBNull.Value))
                {
                    CheckEdit2.Checked = false;
                    CheckEdit2.Refresh();
                }
                else
                {
                    CheckEdit2.Checked = true;
                    //  CheckEdit2.EditValue = dsdrawings.Tables("tblGeneral").Rows(0).Item("genpdf2")
                    CheckEdit2.Refresh();
                }
            }
            catch (Exception ex)
            {
                CheckEdit2.CheckState = CheckState.Unchecked;
            }

        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    groupGeneral_LostFocus(object sender, System.EventArgs e)
        {
            daGeneral.Update(dsdrawings, "tblGeneral");
        }
        //
        #endregion
        //
        #region Grid Manipulation

        private void  // ERROR: Handles clauses are not supported in C#
    viewGeneral_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {

            viewGeneral.SetRowCellValue(e.RowHandle, "plNotesId", this.PlanNumber);
            viewGeneral.SetRowCellValue(e.RowHandle, "plNotestext", "G");
            viewGeneral.SetRowCellValue(e.RowHandle, "plTV", "0");
            viewGeneral.SetRowCellValue(e.RowHandle, "plFrom", "0");
            viewGeneral.SetRowCellValue(e.RowHandle, "plThru", "0");
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewGeneral_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
        {
            //   daNotes.Update(dsdrawings, "tblNotes")
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewTools_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            const int INDEX = 0;

            object value = rpTvParts.Items[INDEX];//JMR -- DEV -- look at -- changed rpTvParts(items) to rpTvParts.Items[INDEX] -- I wonder if rpTvParts should be this.rpTvParts

            viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlTypeVer", "0");
            viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "0");
            viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "0");
            viewTools.SetRowCellValue(e.RowHandle, "tlPlid", PlanNumber);
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewTools_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
        {
            try
            {
                daTools.AcceptChangesDuringUpdate = true;
                daTools.Update(dsdrawings, "tbltools");
            }
            catch (Exception ex)
            {

            }

        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewDrawings_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            //Set value for Hidden Column
            viewDrawings.SetRowCellValue(e.RowHandle, "DwgPlId", PlanNumber);
            viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgTypever", "0");
            viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "0");
            viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "0");
            viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgEcn", "9999");
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewDrawings_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
        {
            try
            {
                daDrawings.AcceptChangesDuringUpdate = true;

                daDrawings.Update(dsdrawings, "tbldrawings");
            }
            catch (Exception ex)
            {

            }
            //'
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewParts_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
        {

            try
            {
                daAssemply.AcceptChangesDuringUpdate = true;
                daAssemply.Update(dsdrawings, "tblAssembly");
            }
            catch (Exception ex)
            {

            }
            //  
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewParts_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.Name != "colprtQty")
            {
                return;
            }
            else
            {
                try
                {
                    newqty = Conversions.ToString(viewParts.GetFocusedRowCellValue("prtQty"));//JMR converted to string
                }
                catch (Exception ex)
                {

                }

                if (oldqty != newqty)
                {
                    viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtKCL", "-");
                }

            }
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewParts_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtEcp", "-");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtPlid", this.PlanNumber);
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFlag", "-");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtAction", "ADD");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtDwgZone", "-");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtTypeVer", "0");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "0");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "0");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtDash", "-");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtInit", "C");
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtKCL", "-");
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_DoubleClick(object sender, System.EventArgs e)
        {
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            string str = this.viewSteps.FocusedColumn.ToString();
            Module1.newModule.rowhan = viewSteps.FocusedRowHandle;
            if (((object.ReferenceEquals(this.viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote"), DBNull.Value)) | (this.viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote") == null)))
            {
                Module1.newModule.rowt = "";
            }
            else if ((Module1.newModule.rowt == "new"))
            {
                Module1.newModule.rowt = "";
            }
            else
            {
                Module1.newModule.rowt = Conversions.ToString(this.viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote"));
            }
            frmStepParts parts = new frmStepParts();
            Module1.newModule.stpParts = true;
            parts.gridStepParts.DataSource = RuntimeHelpers.GetObjectValue(this.gridParts.DataSource);
            parts.gridStepParts.DataMember = this.gridParts.DataMember;
            parts.ShowDialog();
            if (Module1.newModule.PartsStep == Module1.newModule.rowt)
            {
            }
            else
            {
                this.viewSteps.SetFocusedRowCellValue("tmpNote", (Module1.newModule.PartsStep + thirteen + ten + Module1.newModule.rowt));
                if (1 == 2)
                {

                }

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_GotFocus(object sender, System.EventArgs e)
        {

        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            if (CheckEdit1.Checked)
            {
                int ka;
                try
                {
                    ka = Conversions.ToInteger(dsdrawings.Tables[2].Compute("max(tmpStep)", "")) + 5;//JMR -- Converted to int

                }
                catch (Exception ex)
                {
                    ka = 5;
                }

                viewSteps.SetRowCellValue(e.RowHandle, "tmpStep", ka);

            }
            viewSteps.SetRowCellValue(e.RowHandle, "tmpPlid", this.PlanNumber);
            // Dim value = RepositoryItemComboBox1.Items(INDEX)
            viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpTypeVer", "0");
            viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "0");
            viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "0");

            Module1.newModule.rowha = e.RowHandle;
            Module1.newModule.PartsStep = null;
            //StepIncrease += 5
            //viewsteps.setrowcellvalue(e.rowhandle,"tmpStep",stepincrease)
            viewSteps.SetRowCellValue(e.RowHandle, "tmpPlid", PlanNumber);

        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
        {
            //
            try
            {
                daSteps.AcceptChangesDuringUpdate = true;
                daSteps.Update(dsdrawings, "tblTemplate");
            }
            catch (Exception ex)
            {

            }

        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            Module1.newModule.rowhan = e.RowHandle;
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    viewSteps_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
        {
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            if ((this.chkParts.Checked && (Conversions.ToString(this.viewSteps.FocusedColumn) == "NOTE")))
            {
                if ((object.ReferenceEquals(this.viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote"), DBNull.Value)))
                {
                    Module1.newModule.rowt = "";
                }
                else
                {
                    Module1.newModule.rowt = Conversions.ToString(this.viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote"));
                }
                frmStepParts parts = new frmStepParts();
                Module1.newModule.stpParts = true;
                parts.gridStepParts.DataSource = RuntimeHelpers.GetObjectValue(this.gridParts.DataSource);
                parts.gridStepParts.DataMember = this.gridParts.DataMember;
                parts.ShowDialog();
                if ((Module1.newModule.PartsStep != null))
                {
                    if (Module1.newModule.rowt.StartsWith("Obtain the Following"))
                    {
                        Module1.newModule.ResultS = "Obtain the Following Parts from Kit or Bench Stock:";
                        Module1.newModule.ResultS = (Module1.newModule.ResultS + thirteen + ten);
                        Module1.newModule.ResultS = (Module1.newModule.ResultS + "QTY     PART NUMBER       DESCRIPTION       ACTION    DWZONE");
                        Module1.newModule.ResultS = (Module1.newModule.ResultS + thirteen + ten);
                        Module1.newModule.rowt = Module1.newModule.rowt.Replace(Module1.newModule.ResultS, (Module1.newModule.PartsStep + thirteen + ten));
                    }
                    else
                    {
                        Module1.newModule.rowt = (Module1.newModule.PartsStep + thirteen + ten + Module1.newModule.rowt);
                    }
                    this.viewSteps.SetFocusedRowCellValue("tmpNote", Module1.newModule.rowt);
                }
            }
        }


        #endregion
        //
        #region Buttons
        private void  // ERROR: Handles clauses are not supported in C#
    btnSave_Click(object sender, System.EventArgs e)
        {
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            this.bdGeneralOps.EndEdit();
            try
            {
                daGeneral.AcceptChangesDuringUpdate = true;
                daGeneral.Update(dsdrawings, "tblGeneral");
            }
            catch (Exception ex)
            {

            }
            try
            {
                daSteps.AcceptChangesDuringUpdate = true;
                daSteps.Update(dsdrawings, "tblTemplate");
            }
            catch (Exception ex)
            {

            }
            try
            {
                this.daEffectivities.Update(this.dsdrawings, "tblEffectivities");
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            clsData data = new clsData();
            DataSet aset = data.getData(("SELECT * FROM TBLEFFECTIVITIES WHERE EFFROM <>'0' AND EFTHRU <>'0' AND EFPLID = '" + this.PlanNumber + "'"));
            if ((aset.Tables[0].Rows.Count != 0))
            {
                string str2 = "";//JMR -- nulled it
                int num2 = (aset.Tables[0].Rows.Count - 1);
                int i = 0;
                while ((i <= num2))
                {
                    string str = Conversions.ToString(aset.Tables[0].Rows[i]["efFrom"]);
                    string str4 = Conversions.ToString(aset.Tables[0].Rows[i]["efTypeVer"]);
                    string str5 = Conversions.ToString(aset.Tables[0].Rows[i]["efThru"]);
                    string str3 = string.Concat(new string[] {
            str4,
            "-",
            str,
            "-",
            str5
          });
                    if ((i == 0))
                    {
                        str2 = str3;
                    }
                    else
                    {
                        str2 = (str2 + "," + str3);
                    }
                    i += 1;
                }
                data.ExecuteSQL(string.Concat(new string[] {
          "UPDATE TBLGENERAL SET GENTYPEVER ='",
          str2,
          "' WHERE GENPLID ='",
          this.PlanNumber,
          "'"
        }));
                this.lblTypeVer.Text = ("TYPE VER: " + str2);
            }
            try
            {
                this.daRevision.Update(this.dsdrawings, "pdfWires");
            }
            catch (Exception exception9)
            {
                ProjectData.SetProjectError(exception9);
                Exception exception2 = exception9;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daSteps.Update(this.dsdrawings, "tblTemplate");
            }
            catch (Exception exception10)
            {
                ProjectData.SetProjectError(exception10);
                Exception exception3 = exception10;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daGeneral.Update(this.dsdrawings, "tblGeneral");
            }
            catch (Exception exception11)
            {
                ProjectData.SetProjectError(exception11);
                Exception exception4 = exception11;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daAssemply.Update(this.dsdrawings, "tblAssembly");
            }
            catch (Exception exception12)
            {
                ProjectData.SetProjectError(exception12);
                Exception exception5 = exception12;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daDrawings.Update(this.dsdrawings, "tblDrawings");
            }
            catch (Exception exception13)
            {
                ProjectData.SetProjectError(exception13);
                Exception exception6 = exception13;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daNotes.Update(this.dsdrawings, "tblNotes");
            }
            catch (Exception exception14)
            {
                ProjectData.SetProjectError(exception14);
                Exception exception7 = exception14;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daTools.Update(this.dsdrawings, "tblTools");
            }
            catch (Exception exception15)
            {
                ProjectData.SetProjectError(exception15);
                Exception exception8 = exception15;
                ProjectData.ClearProjectError();
            }
            XtraMessageBox.Show("Planning Card Saved! " + thirteen + ten);
        }

        //
        private void  // ERROR: Handles clauses are not supported in C#
    btnAddParts_Click(object sender, System.EventArgs e)
        {
            //If chkParts.Checked Then
            //    Dim FOC As String
            //    FOC = viewSteps.FocusedColumn.ToString



            //    If viewSteps.FocusedColumn.ToString = "Note" Then
            //        'Get rowHandle
            //        rowt = viewSteps.GetRowCellValue(rowhan, "tmpNote")
            //        'Create Form for Displaying Parts and Call as dialog
            //        Dim frm As New frmStepParts
            //        stpParts = True

            //        frm.gridStepParts.DataSource = gridParts.DataSource
            //        frm.gridStepParts.DataMember = gridParts.DataMember
            //        frm.ShowDialog()
            //        'Paste Data int the Cell
            //        viewSteps.SetFocusedRowCellValue("tmpNote", PartsStep & rowt)
            //    End If
            //End If
        }
        //
        private void  // ERROR: Handles clauses are not supported in C#
    btnPreview_Click(object sender, System.EventArgs e)
        {
            // Me.ActiveControl(Me.txtDescription)
            try
            {
                this.daDrawings.Update(this.dsdrawings, "tbldrawings");
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            try
            {
                this.daSteps.Update(this.dsdrawings, "tbldrawings");
            }
            catch (Exception exception3)
            {
                ProjectData.SetProjectError(exception3);
                Exception exception2 = exception3;
                ProjectData.ClearProjectError();
            }
            xrM1ain rmain = new xrM1ain();
            try
            {
                if (CheckEdit2.EditValue == "-")
                {
                    rmain.XrLabel2.Text = "Technician signature______________   Quality Signature______________                                                                                                                                          ";

                }
                else
                {
                    rmain.XrLabel2.Text = "Technician signature______________   Quality Signature______________                                                                                                                                          " + System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine + " DCMA Signature _____________";

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR");
                rmain.XrLabel2.Text = "Technician signature______________   Quality Signature______________                                                                                                 ";
            }



            rmain.txtCardTitle.Text = frmMain.start.cmbProgram.Text;
            rmain.txtCardNo1.Text = this.txtPlanType.Text;
            rmain.TXTECP.Text = txtEcp.Text;
            rmain.txtCardNo.Text = this.txtPartNumber.Text;
            rmain.txtTeam.Text = this.txtTeam.Text;
            rmain.txtRev.Text = this.txtRev.Text;
            rmain.grdRevision.DataSource = this.dsdrawings.Tables["pdfWires"];
            rmain.gridDrawings.DataSource = this.dsdrawings.Tables["tbldrawings"];
            rmain.gridTools.DataSource = this.dsdrawings.Tables["tbltools"];
            rmain.gridParts.DataSource = this.dsdrawings.Tables["tblAssembly"];
            rmain.gridSteps.DataSource = this.dsdrawings.Tables["tblTemplate"];
            rmain.gridGeneral.DataSource = this.dsdrawings.Tables["tblNotes"];
            rmain.GridControl1.DataSource = this.dsdrawings.Tables["tblEffectivities"];

            rmain.ShowPreview();
            rmain.txtDesPage.Text = this.txtDescription.Text;

        }

        #endregion
        //

        private void  // ERROR: Handles clauses are not supported in C#
    btnAnalyzeAssembly_Click(System.Object sender, System.EventArgs e)
        {
            frmAssemply assemply = new frmAssemply();
            Module1.newModule.BAckhrn = false;
            assemply.ShowDialog();
            this.daAssemply.Fill(this.dsdrawings, "tblAssembly");
        }
        private void fillgrid(ListBox lst)//JMR -- DEV -- look at -- changed private object fillgrid to private void fillgrid because it wasn't returning anything.
        {
            clsData dc = new clsData();
            string SQL;
            int i = 0;
            string Act;

            DataSet DS = new DataSet();


            Act = null;
            while ((i <= (lst.Items.Count - 1)))
            {
                //pr1.Properties.Maximum = (lst.Items.Count - 1)



                //pr1.EditValue = i
                //pr1.Update()
                //If txt1.Text = "" Or txt1.Text = "-" Then
                //    ACTION = "ADDED"

                //End If
                //If txt2.Text = "" Or txt2.Text = "-" Then
                //    ACTION = "REMOVED"

                //End If

                string line;
                if ((object.ReferenceEquals(lst, this.lstPartsAssy)))
                {
                    lstPartsAssy.SelectedIndex = i;
                    line = this.lstPartsAssy.Text;


                    this.AnalyzeAssy(line);
                    if (txtprtAction.Text == "A")
                    {
                        txtprtAction.Text = "ADD";
                    }
                    if (txtprtAction.Text == "D")
                    {
                        txtprtAction.Text = "DELETE";
                    }
                    //If txtprtEcp.Text <> ECP Then
                    //    If EcpParts = True Then
                    //        flag = txtprtFlag.Text
                    //        SQL = "INSERT INTO tblAssembly"
                    //        SQL = SQL & "(prtPlid,prtDash,prtQty,prtPartNumberDoc,prtDescription,prtEcp,prtFlag,prtAction,prtDwgZone,prtTypeVer,prtFrom,prtThru) VALUES"
                    //        SQL = SQL & "(" & PlanNumber & ",'" & txtPartsDash.Text & "','" & txtPartsQty.Text & "','" & txtPartNumberDoc.Text & "','" & txtprtDescription.Text & "','" & txtprtEcp.Text & "','" & txtprtFlag.Text & "','" & txtprtAction.Text & "','" & txtprtDwgZone.Text & "','',1,9999)"

                    //        dc.ExecuteSQL(SQL)

                    //    End If
                    //End If
                    //If txtprtEcp.Text = ECP Then
                    //    If EcpParts = False Then
                    //        flag = txtprtFlag.Text
                    //        SQL = "INSERT INTO tblAssembly"
                    //        SQL = SQL & "(prtPlid,prtDash,prtQty,prtPartNumberDoc,prtDescription,prtEcp,prtFlag,prtAction,prtDwgZone,prtTypever,prtFrom,prtThru) VALUES"
                    //        SQL = SQL & "(" & PlanNumber & ",'" & txtPartsDash.Text & "','" & txtPartsQty.Text & "','" & txtPartNumberDoc.Text & "','" & txtprtDescription.Text & "','" & txtprtEcp.Text & "','" & txtprtFlag.Text & "','" & txtprtAction.Text & "','" & txtprtDwgZone.Text & "','999',1,9999)"
                    //        dc.ExecuteSQL(SQL)
                    //    End If

                    //End If

                    clsData FD = new clsData();
                    i = i + 1;
                    string str28 = "INSERT INTO TBLTEMPLATE ";
                    str28 = (str28 + "(TMPPLID,TMPSTEP,TMPNOTE,TMPSTAMP,TMPTYPEVER,TMPFROM,TMPTHRU) VALUES ('" + this.PlanNumber + "'," + i * 5 + ",'" + line + "'," + false + ",'0','0','0')");
                    FD.ExecuteSQL(str28);

                }
            }

            //JMR -- DEV -- look at -- changed 13 to true, because in VB all values besides 0 are true
            if (Module1.newModule.EcpParts == true)
            {
                //EcpParts = True
                fillgrid(lstPartsAssy);
                //SQL = String.Format("delete * from tblAssembly where prtEcp <> '{0}'", ECP)
                //dc.ExecuteSQL(SQL)

                //EcpParts = False
            }

        }
        private void AnalyzeAssy(string line)
        {

            int ACTID;
            if (line == "" | line.Length < 20)
            {
                return;
            }
            ACTID = line.Length;
            //Me.txtPartsDash.Text = line.Substring(3, 5).Trim
            //Me.txtPartsQty.Text = line.Substring(10, 4).Trim
            //Me.txtPartNumberDoc.Text = line.Substring(15, 25).Trim
            //assyPartNumber = txtPartNumberDoc.Text
            //Me.txtprtDescription.Text = line.Substring(40, 22).Trim
            //Me.txtprtEcp.Text = line.Substring(62, 5).Trim
            //Me.txtprtFlag.Text = line.Substring(67, 2).Trim
            //If line.Length > 72 Then
            //    Me.txtprtAction.Text = line.Substring(70, 3).Trim
            //    Me.txtprtDwgZone.Text = line.Substring(73).Trim
            //    DWGZONE = txtprtDwgZone.Text
            //Else
            //    Me.txtprtAction.Text = line.Substring(69).Trim
            //    Me.txtprtDwgZone.Text = ""

            //End If

            //Me.txtprtAction.Text = line.Substring(78, 2).Trim
            //Me.txprtEcp.Text = line.Substring(80).Trim



            //If txt2.Text = "" Then

            //    ACTION = "ADDED PARTS"
            //    ACTID = 4
            //End If
            //If txt3.Text = "" Then
            //    ACTID = 2
            //    txt3.Text = "-"
            //End If
            //'Dim dc As New clsData
            //'Dim SQL As String
        }




        private void  // ERROR: Handles clauses are not supported in C#
    viewParts_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (object.ReferenceEquals((viewParts.GetRowCellValue(e.RowHandle, "prtFlag")), DBNull.Value))
            {
                return;
            }
            if (Module1.newModule.style == true)
            {
                if ((viewParts.GetRowCellValue(e.RowHandle, "prtFlag")) == "Y")
                {
                    e.Appearance.BackColor = Color.Aqua;
                }
            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnAddPart_Click(object sender, System.EventArgs e)
        {
            if (chkParts.Checked)
            {
                string FOC;
                FOC = viewSteps.FocusedColumn.ToString();



                if (viewSteps.FocusedColumn.ToString() == "Note")
                {
                    //Get rowHandle
                    Module1.newModule.rowt = viewSteps.GetRowCellValue(Module1.newModule.rowhan, "tmpNote").ToString();
                    //Create Form for Displaying Parts and Call as dialog
                    frmStepParts frm = new frmStepParts();
                    Module1.newModule.stpParts = true;

                    frm.gridStepParts.DataSource = gridParts.DataSource;
                    frm.gridStepParts.DataMember = gridParts.DataMember;
                    frm.ShowDialog();
                    //Paste Data int the Cell
                    viewSteps.SetFocusedRowCellValue("tmpNote", Module1.newModule.PartsStep + Module1.newModule.rowt);
                }
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnAddEcn_Click(System.Object sender, System.EventArgs e)
        {
            using (frmSel frm = new frmSel())
            {
                frm.ShowDialog();
            }
            daDrawings.Fill(dsdrawings, "tblDrawings");
            gridDrawings.Refresh();
        }

        private void SimpleButton1_Click(System.Object sender, System.EventArgs e)
        {
            XRDesignRibbonForm form = new XRDesignRibbonForm();//JMR -- changed XRDesignRibbonFormEx to XRDesignRibbonForm because XRDesignRibbonFormEx is obsolete.
            form.OpenReport(new xrPartsPreview());
            form.ShowDialog();

        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewEffectivity_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            viewEffectivity.SetRowCellValue(e.RowHandle, "efPlId", PlanNumber);
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewEffectivity_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            try
            {
                daEffectivities.Update(dsdrawings, "tblEffectivities");
            }
            catch (Exception ex)
            {

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewTools_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewRevision_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            viewRevision.SetRowCellValue(e.RowHandle, "TERM", this.PlanNumber);
            viewRevision.SetRowCellValue(e.RowHandle, "HARNESS", "0");
            viewRevision.SetRowCellValue(e.RowHandle, "LENGTH", "0");
            viewRevision.SetRowCellValue(e.RowHandle, "DASH", "0");
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewRevision_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            try
            {
                daRevision.Update(dsdrawings, "pdfWires");

            }
            catch (Exception ex)
            {

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewGeneral_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            try
            {
                daNotes.AcceptChangesDuringUpdate = true;
                daNotes.Update(dsdrawings, "tblNotes");

            }
            catch (Exception ex)
            {

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem4_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.btnSave.PerformClick();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem7_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //  Me.btnAddEcn.PerformClick()

        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem6_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SimpleButton2.PerformClick();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem5_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.Close();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem11_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            btnExport.PerformClick();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem12_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            btnImport.PerformClick();

        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem9_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            btnPreview.PerformClick();

        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem17_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            btnAddEcn.PerformClick();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton2_Click(System.Object sender, System.EventArgs e)
        {
            clsData data = new clsData();
            string oldValue = null;
            string newValue = null;
            this.daDrawings.Fill(this.dsdrawings, "tblDrawings");

            DataSet set2 = new DataSet();
            set2 = new clsData().getData(("SELECT COMMENT FROM TBLECN WHERE COMMENT LIKE '%" + this.txtPartNumber.Text + "%'"));
            int num2 = (set2.Tables[0].Rows.Count - 1);
            int i = 0;
            while ((i <= num2))
            {
                Module1.newModule.ecnComment = Conversions.ToString(set2.Tables[0].Rows[i]["COMMENT"]);
                if ((Module1.newModule.ecnComment == ("Started Pl/c  " + Module1.newModule.STRPLANO)))
                {
                    newValue = ("Finished Pl/c " + Module1.newModule.STRPLANO);
                    Module1.newModule.stath = Module1.newModule.ecnComment.Replace(Module1.newModule.ecnComment, newValue);
                }
                else if (Module1.newModule.ecnComment.Contains("Finished Pl/c"))
                {
                    Module1.newModule.stath = Module1.newModule.ecnComment.Replace(Module1.newModule.STRPLANO, "");
                    Module1.newModule.stath = Module1.newModule.ecnComment.Replace("Finished Pl/c", ("Finished Pl/c " + this.txtPartNumber.Text + " , "));
                }
                else
                {
                    Module1.newModule.stath = Module1.newModule.ecnComment.Replace(Module1.newModule.STRPLANO, "");
                    Module1.newModule.stath = (Module1.newModule.stath + "  and Finished Pl/c " + this.txtPartNumber.Text);
                }
                data.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblEcn set  comment ='",
          Module1.newModule.stath,
          " 'where COMMENT = '",
          Module1.newModule.ecnComment,
          "'"
        }));
                i += 1;
            }
            data.ExecuteSQL(("UPDATE TBLGENERAL SET genComparison ='F' WHERE GENPLID = '" + this.PlanNumber + "'"));
            //num2 = (Me.dsdrawings.Tables.Item("tblDrawings").Rows.Count - 1)
            //i = 0

            //Do While (i <= num2)
            //    Dim stath As String
            //    Module1.stath = Conversions.ToString(Me.dsdrawings.Tables.Item("tblDrawings").Rows.Item(i).Item("dwgEcn"))
            //    If (Module1.stath <> stath) AndAlso Module1.stath <> "9999" AndAlso Module1.stath <> "-" Then
            //        Module1.ecnComment = Conversions.ToString(data.getData(("select comment FROM TBLECN WHERE ecn = '" & Module1.stath & "'")).Tables.Item(0).Rows.Item(0).Item("COMMENT"))
            //        oldValue = ("Started Pl/c " & Module1.STRPLANO)
            //        newValue = ("Finished Pl/c " & Module1.STRPLANO)
            //        Module1.ecnComment = Module1.ecnComment.Replace(oldValue, newValue)
            //        data.ExecuteSQL(String.Concat(New String() {"UPDATE tblEcn set  comment ='", Module1.ecnComment, " 'where ECN = '", Module1.stath, "'"}))
            //        stath = Module1.stath
            //    End If
            //    i += 1
            //Loop
            data.ExecuteSQL(("UPDATE TBLGENERAL SET genComparison ='F' WHERE GENPLID = '" + this.PlanNumber + "'"));
            XtraMessageBox.Show(("The Planning Card " + Module1.newModule.STRPLANO + " Finished"), "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnExport_Click(System.Object sender, System.EventArgs e)
        {
            clsData data = new clsData();
            Module1.newModule.Createadapter(this.dsTransfer, "pdfWires", ("TERM ='" + this.PlanNumber + "'"), ref this.daTransferRevision);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresRemove", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRemove);
            Module1.newModule.Createadapter(this.dsTransfer, "tblBackShopWires", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferBackShop);
            Module1.newModule.Createadapter(this.dsTransfer, "tblCont", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferCont);
            Module1.newModule.Createadapter(this.dsTransfer, "tblDrawings", ("DwgPlId ='" + this.PlanNumber + "'"), ref this.daTransferDrawings);
            Module1.newModule.Createadapter(this.dsTransfer, "tblTools", ("tlPlid ='" + this.PlanNumber + "'"), ref this.daTransferTools);
            Module1.newModule.Createadapter(this.dsTransfer, "tblEffectivities", ("efPlId = '" + this.PlanNumber + "'"), ref this.daTransferEffectivities);
            Module1.newModule.Createadapter(this.dsTransfer, "tblGeneral", ("genPlId = '" + this.PlanNumber + "'"), ref this.daTransferGeneral);
            Module1.newModule.Createadapter(this.dsTransfer, "tblmisc", ("MISCPLANID = '" + this.PlanNumber + "'"), ref this.daTransferMisc);
            Module1.newModule.Createadapter(this.dsTransfer, "tblNotes", ("plNotesId = '" + this.PlanNumber + "'"), ref this.daTransferNotes);
            Module1.newModule.Createadapter(this.dsTransfer, "tblPlano", ("PlannoId = '" + this.PlanNumber + "'"), ref this.daTransferPlano);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRefDes", ("RefPlanId = '" + this.PlanNumber + "'"), ref this.daTransferRefDes);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRefDesComp", ("REFCOMPPLID ='" + this.PlanNumber + "'"), ref this.daTransferRefDesComp);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRoute", ("rPlId ='" + this.PlanNumber + "'"), ref this.daTransferRoute);
            Module1.newModule.Createadapter(this.dsTransfer, "tblSelHarness", ("hrnSelPlId ='" + this.PlanNumber + "'"), ref this.daTransferSelHarness);
            Module1.newModule.Createadapter(this.dsTransfer, "tblTemplate", ("tmpPlid ='" + this.PlanNumber + "'"), ref this.daTransferTemplate);
            Module1.newModule.Createadapter(this.dsTransfer, "tblAssembly", ("prtPlId = '" + this.PlanNumber + "'"), ref this.daTransferAssembly);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWires", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWires);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresAdd", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresAdd);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresRevise", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRevise);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresBackshell", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresBackshell);
            SaveFileDialog dialog = new SaveFileDialog { Filter = "xml files (*.xml)|*.xml" };
            if ((dialog.ShowDialog() == DialogResult.OK))
            {
                string fileName = dialog.FileName;
                this.dsTransfer.WriteXml(fileName);
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnImport_Click(System.Object sender, System.EventArgs e)
        {
            DataSet ds = new DataSet();
            clsData data2 = new clsData();
            string planNumber = this.PlanNumber;
            this.PlanNumber = "9999999999999";
            Module1.newModule.Createadapter(this.dsTransfer, "tblBackShopWires", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferBackShop);
            Module1.newModule.Createadapter(this.dsTransfer, "tblCont", ("bacPlId ='" + this.PlanNumber + "'"), ref this.daTransferCont);
            Module1.newModule.Createadapter(this.dsTransfer, "pdfWires", ("TERM ='" + this.PlanNumber + "'"), ref this.daTransferRevision);
            Module1.newModule.Createadapter(this.dsTransfer, "tblDrawings", ("DwgPlId ='" + this.PlanNumber + "'"), ref this.daTransferDrawings);
            Module1.newModule.Createadapter(this.dsTransfer, "tblTools", ("tlPlid ='" + this.PlanNumber + "'"), ref this.daTransferTools);
            Module1.newModule.Createadapter(this.dsTransfer, "tblEffectivities", ("efPlId = '" + this.PlanNumber + "'"), ref this.daTransferEffectivities);
            Module1.newModule.Createadapter(this.dsTransfer, "tblGeneral", ("genPlId = '" + this.PlanNumber + "'"), ref this.daTransferGeneral);
            Module1.newModule.Createadapter(this.dsTransfer, "tblmisc", ("miscPlanId = '" + this.PlanNumber + "'"), ref this.daTransferMisc);
            Module1.newModule.Createadapter(this.dsTransfer, "tblNotes", ("plNotesId = '" + this.PlanNumber + "'"), ref this.daTransferNotes);
            Module1.newModule.Createadapter(this.dsTransfer, "tblPlano", ("PlannoId = '" + this.PlanNumber + "'"), ref this.daTransferPlano);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRefDes", ("RefPlanId = '" + this.PlanNumber + "'"), ref this.daTransferRefDes);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRefDesComp", ("REFCOMPPLID ='" + this.PlanNumber + "'"), ref this.daTransferRefDesComp);
            Module1.newModule.Createadapter(this.dsTransfer, "tblRoute", ("rPlId ='" + this.PlanNumber + "'"), ref this.daTransferRoute);
            Module1.newModule.Createadapter(this.dsTransfer, "tblSelHarness", ("hrnSelPlId ='" + this.PlanNumber + "'"), ref this.daTransferSelHarness);
            Module1.newModule.Createadapter(this.dsTransfer, "tblTemplate", ("tmpPLID ='" + this.PlanNumber + "'"), ref this.daTransferTemplate);
            Module1.newModule.Createadapter(this.dsTransfer, "tblAssembly", ("prtPlId = '" + this.PlanNumber + "'"), ref this.daTransferAssembly);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWires", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWires);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresAdd", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresAdd);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresRemove", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRemove);
            Module1.newModule.Createadapter(this.dsTransfer, "tblWiresRevise", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresRevise);
            Module1.newModule.Createadapter(ds, "tblWiresBackshell", (" WIRESPLID ='" + this.PlanNumber + "'"), ref this.daTransferWiresBackshell);
            this.dsTransfer.WriteXmlSchema((Application.StartupPath + "\\test.XML"));
            this.PlanNumber = planNumber;
            OpenFileDialog dialog = new OpenFileDialog();
            DataSet set4 = new DataSet();
            DataSet set5 = new DataSet();
            dialog.Filter = "xml files (*.xml)|*.xml";
            if ((dialog.ShowDialog() == DialogResult.OK))
            {
                string fileName = dialog.FileName;
                //set4.ReadXmlSchema(fileName)
                set4.ReadXmlSchema((Application.StartupPath + "\\test.XML"));

                try
                {
                    set4.ReadXml(fileName);

                }
                catch (Exception ex)
                {
                    set4.ReadXml(fileName);
                }

                try
                {
                    this.dsTransfer = set4.Copy();
                    this.txtPartNumber.Text = Module1.newModule.STRPLANO;
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    ProjectData.ClearProjectError();
                }
                try
                {
                    planNumber = Conversions.ToString(set4.Tables["tblGeneral"].Rows[0]["genPlId"]);
                    if ((planNumber != this.PlanNumber))
                    {
                        //
                    }
                }
                catch (Exception exception3)
                {
                    ProjectData.SetProjectError(exception3);
                    Exception exception2 = exception3;
                    ProjectData.ClearProjectError();
                }
                if ((XtraMessageBox.Show("Overwrite existing data?", "Update card", MessageBoxButtons.YesNo) == DialogResult.No))
                {
                    XtraMessageBox.Show("Update canceled.");
                    return;
                }
                if ((planNumber == this.PlanNumber))
                {
                    data2.ExecuteSQL(("update tblGeneral set  genPlid ='999999999' where genPlId = '" + planNumber + "'"));
                    Module1.newModule.ClearCard(planNumber);

                }
                else
                {
                    Module1.newModule.ClearCard(this.PlanNumber);
                    Module1.newModule.ClearCard(planNumber);
                    data2.ExecuteSQL(("update tblGeneral set  genPlid ='999999999' where genPlId = '" + this.PlanNumber + "'"));
                    Module1.newModule.Iscarddif = true;
                    try
                    {
                        DataRow[] FOUNDROWS6E;//JMR -- look at -- took Data. off Data.DataRow[]
                        DataRow OW21;
                        FOUNDROWS6E = frmCards.newfrmCards1.dsCards.Tables[1].Select("genPlId = '" + this.PlanNumber + "'");
                        OW21 = FOUNDROWS6E[0];
                        frmCards.newfrmCards1.dsCards.Tables[1].Rows.Remove(OW21);
                    }
                    catch (Exception ex)
                    {

                    }
                    try
                    {
                        DataRow[] FOUNDROWS6E;//JMR -- look at -- took Data. off Data.DataRow[]
                        DataRow OW21;
                        FOUNDROWS6E = frmCards.newfrmCards1.dsCards.Tables[1].Select("genPlId = '999999999'");
                        OW21 = FOUNDROWS6E[0];
                        frmCards.newfrmCards1.dsCards.Tables[1].Rows.Remove(OW21);
                    }
                    catch (Exception ex)
                    {

                    }
                    //   data2.ExecuteSQL(("update tblGeneral set  genPlid ='" & planNumber & "' where genPlId = '" & Me.PlanNumber & "'"))
                }
                try
                {
                    this.daTransferAssembly.Update(this.dsTransfer, "tblAssembly");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferBackShop.Update(this.dsTransfer, "tblBackShopWires");
                }
                catch (Exception ex)
                {

                }

                try
                {
                    this.daTransferCont.Update(this.dsTransfer, "tblCont");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferDrawings.Update(this.dsTransfer, "tblDrawings");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferEffectivities.Update(this.dsTransfer, "tblEffectivities");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferGeneral.Update(this.dsTransfer, "tblGeneral");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferRevision.Update(this.dsTransfer, "pdfWires");
                }
                catch (Exception ex)
                {

                }

                try
                {
                    this.daTransferNotes.Update(this.dsTransfer, "tblNotes");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferRefDes.Update(this.dsTransfer, "tblRefDes");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferRefDesComp.Update(this.dsTransfer, "tblRefDesComp");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferRoute.Update(this.dsTransfer, "tblRoute");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferSelHarness.Update(this.dsTransfer, "tblSelHarness");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferTemplate.Update(this.dsTransfer, "tblTemplate");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferTools.Update(this.dsTransfer, "tblTools");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferWires.Update(this.dsTransfer, "tblWires");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferWiresAdd.Update(this.dsTransfer, "tblWiresAdd");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferWiresBackshell.Update(this.dsTransfer, "tblWiresBackShell");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferWiresRemove.Update(this.dsTransfer, "tblWiresRemove");
                }
                catch (Exception ex)
                {

                }
                try
                {
                    this.daTransferWiresRevise.Update(this.dsTransfer, "tblWiresRevise");
                }
                catch (Exception ex)
                {

                }
                data2.ExecuteSQL("DELETE * FROM TBLGENERAL WHERE genPlId = '999999999'");
            }
            dsdrawings.Clear();
            this.PlanNumber = planNumber;
            Module1.newModule.Createadapter(this.dsdrawings, "tblNotes", ("plNotesId = '" + this.PlanNumber + "'"), ref this.daNotes);
            Module1.newModule.Createadapter(this.dsdrawings, "tblAssembly", ("prtPlId = '" + this.PlanNumber + "' and prtEcp <> 'simple'"), ref this.daAssemply);
            Module1.newModule.Createadapter(this.dsdrawings, "tblGeneral", ("genPlId = '" + this.PlanNumber + "'"), ref this.daGeneral);
            Module1.newModule.Createadapter(this.dsdrawings, "tbldrawings", ("DWGPLID ='" + this.PlanNumber + "'"), ref this.daDrawings);
            Module1.newModule.Createadapter(this.dsdrawings, "tblTools", ("tlPLID ='" + this.PlanNumber + "'"), ref this.daTools);
            Module1.newModule.Createadapter(this.dsdrawings, "tblTemplate", ("tmpPLID ='" + this.PlanNumber + "'"), ref this.daSteps);

            Module1.newModule.Createadapter(this.dsdrawings, "pdfWires", ("TERM = '" + this.PlanNumber + "'"), ref this.daRevision);
            Module1.newModule.Createadapter(this.dsdrawings, "tblEffectivities", ("efPlId = '" + this.PlanNumber + "'"), ref this.daEffectivities);
            //   GridControl1.RefreshDataSource()
            XtraMessageBox.Show("Card Updated", "update", MessageBoxButtons.OK);
            DataSet set2 = new DataSet();
            DataSet aset = new DataSet();
            clsData data3 = new clsData();
            clsData data = new clsData();
        }

        private void  // ERROR: Handles clauses are not supported in C#
    XtraTabControl1_Click(System.Object sender, System.EventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton1_Click_1(System.Object sender, System.EventArgs e)
        {
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            string str = "";//JMR -- nulled it
            string str2;
            int num;
            string str3;
            SaveFileDialog dialog = new SaveFileDialog();
            xrParts parts = new xrParts();
            DataSet aset = new DataSet();
            clsData data = new clsData();
            DataSet set2 = new DataSet();
            DataSet dataSet = new DataSet();
            DataSet set4 = new DataSet();
            set4 = data.getData("SELECT PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE 1 = 2");
            aset = data.getData(("SELECT distinct PARTNUMBER FROM TBLREFDESCOMP WHERE REFCOMPPLID ='" + this.PlanNumber + "' AND REFACTION ='ADD'"));
            int num6 = (aset.Tables[0].Rows.Count - 1);
            int i = 0;
            while ((i <= num6))
            {
                str2 = Conversions.ToString(aset.Tables[0].Rows[i][0]);
                dataSet = data.getData(string.Concat(new string[] {
                "SELECT  PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE REFCOMPPLID ='",
                this.PlanNumber,
                "' and partnumber ='",
                str2,
                "' and qty <> 'REF' AND REFACTION ='ADD'"
            }));
                if ((dataSet.Tables[0].Rows.Count > 1))
                {
                    num = 0;
                    int num7 = (dataSet.Tables[0].Rows.Count - 1);
                    int k = 0;
                    while ((k <= num7))
                    {
                        if ((k == 0))
                        {
                            num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[k][2]));
                            str = Conversions.ToString(dataSet.Tables[0].Rows[k][3]);
                        }
                        else
                        {
                            str3 = Conversions.ToString(dataSet.Tables[0].Rows[k][2]);
                            try
                            {
                                num = (int)Math.Round((double)(num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[k][2]))));
                                dataSet.Tables[0].Rows[0][2] = num;
                            }
                            catch (Exception ex)
                            {
                                dataSet.Tables[0].Rows[0][2] = (dataSet.Tables[0].Rows[k][2]);
                                XtraMessageBox.Show("Check QTY on parts list");
                            }

                            str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[k][3])));
                            dataSet.Tables[0].Rows[k].Delete();

                            dataSet.Tables[0].Rows[0][3] = str;
                        }
                        k += 1;
                    }
                }
                set4.Merge(dataSet);
                i += 1;
            }
            DataSet set3 = new DataSet();
            set3 = data.getData(("select distinct  prtPartNumberDoc from tblAssembly where prtAction ='ADD' and  prtPlId ='" + this.PlanNumber + "'"));
            int num8 = (set3.Tables[0].Rows.Count - 1);
            int j = 0;
            while ((j <= num8))
            {
                str2 = Conversions.ToString(set3.Tables[0].Rows[j][0]);
                dataSet = data.getData(string.Concat(new string[] {
          "select prtPartNumberDoc,prtDescription,prtQty,prtDwgZone from tblAssembly where  prtPartNumberDoc ='",
          str2,
          "' and prtAction ='ADD' and  prtPlId ='",
          this.PlanNumber,
          "'"
        }));
                try
                {
                    str = Conversions.ToString(dataSet.Tables[0].Rows[0][3]);
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    str = "-";
                    ProjectData.ClearProjectError();
                }
                if (((dataSet.Tables[0].Rows.Count > 1) | !LikeOperator.LikeString(str, "P5374*", CompareMethod.Binary)))
                { 
                    num = 0;
                    int num9 = (dataSet.Tables[0].Rows.Count - 1);
                    int m = 0;
                    while ((m <= num9))
                    {
                        try
                        {
                            if ((Conversions.ToString(dataSet.Tables[0].Rows[m][2]) != "AR"))
                            {
                                if ((m == 0))
                                {
                                    num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[m][2]));
                                    try
                                    {
                                        str = Conversions.ToString(dataSet.Tables[0].Rows[m][3]);
                                    }
                                    catch (Exception exception4)
                                    {
                                        ProjectData.SetProjectError(exception4);
                                        Exception exception2 = exception4;
                                        str = "-";
                                        ProjectData.ClearProjectError();
                                    }
                                }
                                else
                                {
                                    str3 = Conversions.ToString(dataSet.Tables[0].Rows[m][2]);
                                    try
                                    {
                                        num = (int)Math.Round((double)(num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[m][2]))));
                                        dataSet.Tables[0].Rows[0][2] = num;
                                    }
                                    catch (Exception ex)
                                    {
                                        dataSet.Tables[0].Rows[0][2] = (dataSet.Tables[0].Rows[m][2]);
                                        XtraMessageBox.Show("Check QTY on parts list");
                                    }
                                    str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[m][3])));

                                    dataSet.Tables[0].Rows[m][3] = str;
                                    dataSet.Tables[0].Rows[m].Delete();
                                }
                            }
                        }
                        catch (Exception exception5)
                        {
                            ProjectData.SetProjectError(exception5);
                            Exception exception3 = exception5;
                            ProjectData.ClearProjectError();
                        }
                        m += 1;
                    }
                }
                dataSet.Tables[0].Columns[0].ColumnName = "PARTNUMBER";
                dataSet.Tables[0].Columns[1].ColumnName = "DESCRIPTION";
                dataSet.Tables[0].Columns[2].ColumnName = "QTY";
                dataSet.Tables[0].Columns[3].ColumnName = "LOCATION";
                set4.Merge(dataSet);
                j += 1;
            }
            set4.AcceptChanges();
            ExportToExcel(set4.Tables[0], set4.Tables[0], set4.Tables[0]);
            parts.LabelControl1.Text = ("MKPL FOR  " + this.lblTypeVer.Text + "/" + thirteen + ten + this.txtDescription.Text);
            parts.GridControl1.DataSource = set4.Tables[0];
            //parts.ShowPreview()
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpTVSteps_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewSteps.SetRowCellValue(this.viewSteps.FocusedRowHandle, "tmpTypeVer", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "0");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpFrom", "1");
                viewSteps.SetRowCellValue(viewSteps.FocusedRowHandle, "tmpThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpTvTools_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewTools.SetRowCellValue(this.viewTools.FocusedRowHandle, "tlTypeVer", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "0");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlFrom", "1");
                viewTools.SetRowCellValue(viewTools.FocusedRowHandle, "tlThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpTVRev_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewRevision.SetRowCellValue(this.viewRevision.FocusedRowHandle, "HARNESS", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "0");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "LENGTH", "1");
                viewRevision.SetRowCellValue(viewRevision.FocusedRowHandle, "DASH", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpTvParts_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtTypeVer", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "0");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "9999");

            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtFrom", "1");
                this.viewParts.SetRowCellValue(this.viewParts.FocusedRowHandle, "prtThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpTVdrawing_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewDrawings.SetRowCellValue(this.viewDrawings.FocusedRowHandle, "dwgTypever", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "0");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgFrom", "1");
                viewDrawings.SetRowCellValue(viewDrawings.FocusedRowHandle, "dwgThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    rpGenTV_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewGeneral.SetRowCellValue(this.viewGeneral.FocusedRowHandle, "plTV", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "0");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plFrom", "1");
                viewGeneral.SetRowCellValue(viewGeneral.FocusedRowHandle, "plThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    viewParts_ShownEditor(object sender, System.EventArgs e)
        {
            try
            {
                oldqty = viewParts.GetFocusedRowCellValue("prtQty").ToString();
            }
            catch (Exception ex)
            {

            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    gridDrawings_DoubleClick(object sender, System.EventArgs e)
        {
            try
            {

                string str2 = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgEcn"));
                string source = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgPartnumber"));
                Module1.newModule.tv = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgTypever"));
                Module1.newModule.strFrmo = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgFrom"));
                Module1.newModule.strTHRU = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgThru"));
                Module1.newModule.fr = Conversions.ToInteger(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgFrom"));
                Module1.newModule.trhu = Conversions.ToInteger(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgThru"));
                //   Module1.ECP = Conversions.ToString(Me.viewDrawings.GetRowCellValue(Me.viewDrawings.GetSelectedRows(0), "RCN"))
                //Dim str3 As String = Conversions.ToString(Me.viewDrawings.GetRowCellValue(Me.viewDrawings.GetSelectedRows(0), "DRAWINGTITLE"))
                string str4 = Conversions.ToString(this.viewDrawings.GetRowCellValue(this.viewDrawings.GetSelectedRows()[0], "dwgNotes"));
                // Module1.ProgramId = Conversions.ToString(Me.viewDrawings.GetRowCellValue(Me.viewDrawings.GetSelectedRows(0), "COMMENT"))
                Module1.newModule.strFrmo = Module1.newModule.strFrmo.PadLeft(4, '0');
                Module1.newModule.strTHRU = Module1.newModule.strTHRU.PadLeft(4, '0');
                if (source.Contains("-"))
                {
                    source = source.Substring(0, source.IndexOf("-")).Trim();
                }
                clsData data2 = new clsData();
                DataSet DSCOM = new DataSet();
                try
                {
                    DSCOM = data2.getData(string.Concat(new string[] {
            "SELECT * FROM tblEcn where ECN = '",
            str2,
            "' and DRAWING ='",
            source,
            "' and DASH ='",
            str4,
            "'AND TYPEVER ='",
            Module1.newModule.tv,
            "' AND FR0M ='",
            Module1.newModule.strFrmo,
            "' AND THRU='",
            Module1.newModule.strTHRU,
            "'"
          }));
                    Module1.newModule.ProgramId = DSCOM.Tables[0].Rows[0]["COMMENT"].ToString();
                }
                catch (Exception ex)
                {

                }
                if ((((Module1.newModule.ProgramId == "") | LikeOperator.LikeString(Module1.newModule.ProgramId, "*NEW*", CompareMethod.Binary)) | LikeOperator.LikeString(Module1.newModule.ProgramId, "*lanned*", CompareMethod.Binary)))
                {
                    Module1.newModule.ecnComment = "";
                    Module1.newModule.ecnComment = (Module1.newModule.ecnComment + "Started Pl/c " + Module1.newModule.STRPLANO);
                    Module1.newModule.stath = str2;
                }
                else if (Module1.newModule.ProgramId.Contains(Module1.newModule.STRPLANO))
                {
                    Module1.newModule.ecnComment = Module1.newModule.ProgramId;
                }
                else
                {
                    Module1.newModule.ecnComment = Module1.newModule.ProgramId;
                    Module1.newModule.ecnComment = (Module1.newModule.ecnComment + ",");
                    Module1.newModule.startinG = false;
                    Module1.newModule.ecnComment = (Module1.newModule.ecnComment + " Started Pl/c " + Module1.newModule.STRPLANO);
                }
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblEcn set comment ='",
          Module1.newModule.ecnComment,
          "' where ECN = '",
          str2,
          "' and DRAWING ='",
          source,
          "' and DASH ='",
          str4,
          "'AND TYPEVER ='",
          Module1.newModule.tv,
          "' AND FR0M ='",
          Module1.newModule.strFrmo,
          "' AND THRU='",
          Module1.newModule.strTHRU,
          "'"
        }));
            }
            catch (Exception ex)
            {

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    btnAddParts_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton3_Click(System.Object sender, System.EventArgs e)
        {

        }

        private void CheckEdit2_CheckedChanged(System.Object sender, System.EventArgs e)
        {
            try
            {
                daGeneral.AcceptChangesDuringUpdate = true;
                daGeneral.Update(dsdrawings, "tblGeneral");
            }
            catch (Exception ex)
            {

            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    RepositoryItemComboBox8_EditValueChanged(object sender, System.EventArgs e)
        {
            this.viewEffectivity.SetRowCellValue(this.viewEffectivity.FocusedRowHandle, "efTypeVer", ((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem);
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "0")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "0");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "0");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2J")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "14");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "2K")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "4");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HN")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "12");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "HP")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "6");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M28")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "23");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "M29")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "5");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "999")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "9999");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TB")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "30");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TA")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "120");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TP")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "8");
            }
            if (((DevExpress.XtraEditors.ComboBoxEdit)sender).SelectedItem == "TQ")
            {
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efFrom", "1");
                viewEffectivity.SetRowCellValue(viewEffectivity.FocusedRowHandle, "efThru", "4");
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    BarButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DataSet DS = new DataSet();
            OpenFileDialog dialog = new OpenFileDialog();
            DataSet set4 = new DataSet();
            DataSet set5 = new DataSet();
            dialog.Filter = "TXT files (*.TXT)|*.TXT";

            if ((dialog.ShowDialog() == DialogResult.OK))
            {
                XtraTabControl1.Enabled = false;
                string fileName = dialog.FileName;

                StreamReader sr = new StreamReader(fileName);
                bool captureRemove = false;
                bool captureAdd = false;
                bool captureRevise = false;
                bool captureCont = false;
                bool captureParts = false;
                bool captureRefDes = false;
                bool captureWires = false;
                bool capturePinout = false;

                //Clear Old contents

                lstPartsAssy.Items.Clear();



                //Read firstline

                //Get DashNumber of  harness 


                //Read firstline
                string line;

                //et DashNumber of  harness 
                do
                {

                    line = sr.ReadLine();
                    if (line == null)
                    {
                        line = sr.ReadLine();

                    }
                    if (line.Length < 10)
                    {
                        line = sr.ReadLine();
                    }
                    line = line.Substring(3).Trim();

                    if (line.StartsWith("Title: Rework "))
                    {

                        Module1.newModule.GenericCardTitle = line.Substring(0, line.Length).Trim();
                        txtDescription.Text = Module1.newModule.GenericCardTitle;
                        line = sr.ReadLine();
                    }


                    if (line.Length < 10)
                    {
                        line = sr.ReadLine();
                    }
                    if (line == null)
                    {
                        line = "----";
                    }

                    if (line.StartsWith(" QTY1  QTY2    PART NUMBER    NOMENCLATURE   APPL CAGEC   NO     NOTES    ZONE"))
                    {
                        line = sr.ReadLine();
                        line = sr.ReadLine();
                        line = sr.ReadLine();

                        captureParts = true;
                    }
                    if (line.Contains("COMPARISON COMPLETE"))// ERROR: Unknown binary operator Like //JMR -- fixed
                    {

                        captureParts = false;
                        captureRefDes = false;
                        captureWires = false;
                        line = sr.ReadLine();
                        if (line == null)
                        {
                            line = "---";
                        }
                    }
                    //AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("           ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) 

                    this.lstPartsAssy.Items.Add(line);
                    this.lstPartsAssy.Refresh();

                    //If line.StartsWith(" L  LGTH    WIRE NUMBER       CD            END POINT    PSL    TERM PART     E") Then
                    //    line = sr.ReadLine
                    //    ' line = sr.ReadLine
                    //    'line = sr.ReadLine

                    //capturePinout = True
                    //End If
                    if (line.StartsWith("Operation complete"))
                    {
                        capturePinout = false;
                    }
                    //AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("           ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) 



                    if (line.StartsWith(" LGTH LGTH   WIRE NUMBER         CD            REF DES      PSL    TERM PART"))
                    {
                        line = sr.ReadLine();
                        line = sr.ReadLine();
                        line = sr.ReadLine();

                        //  captureWires = True
                    }
                    if (line.StartsWith("       *** COMPARISON COMPLETE ***"))
                    {
                        captureWires = false;
                    }
                    //AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("           ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) 

                    //    If line.StartsWith("        N  ADD THE FOLLOWING WIRES") Then
                    //        line = sr.ReadLine
                    //        line = sr.ReadLine
                    //        line = sr.ReadLine
                    //        line = sr.ReadLine
                    //        captureAdd = True
                    //    End If
                    //    If line.StartsWith("        N  NOTE :") Then
                    //        captureAdd = False
                    //    End If
                    //    If (captureAdd AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("           ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) Then
                    //        Me.lstAddWires.Items.Add(line)
                    //        Me.lstAddWires.Refresh()
                    //    End If
                    //    'If line.StartsWith("        N  REVISE WIRES") Then
                    //    '    line = sr.ReadLine
                    //    '    line = sr.ReadLine
                    //    '    line = sr.ReadLine
                    //    '    'line = sr.ReadLine
                    //    '    captureRevise = True
                    //    'End If
                    //    'If line.StartsWith("        N  HARDWARE CODE ") Then
                    //    '    captureRevise = False
                    //    'End If
                    //    'If (captureRevise AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("           ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) Then

                    //    '    Me.lstReviseWires.Items.Add(line)
                    //    '    Me.lstReviseWires.Refresh()
                    //    'End If
                    //    'If line.StartsWith("N  PERFORM CONTINUITY") Then
                    //    '    line = sr.ReadLine
                    //    '    line = sr.ReadLine
                    //    '    line = sr.ReadLine
                    //    '    line = sr.ReadLine
                    //    '    captureCont = True
                    //    'End If
                    //    'If line.StartsWith("===========") Then
                    //    '    captureCont = False
                    //    'End If
                    //    'If (captureCont AndAlso (((Not line.StartsWith("-----------") AndAlso Not line.StartsWith(" PRINT DATE")) AndAlso (Not line.StartsWith("          ") AndAlso Not line.StartsWith(" PRG : CCIP"))) AndAlso Not (line = ""))) Then
                    //    '    Me.lstcount.Items.Add(line)
                    //    '    Me.lstcount.Refresh()
                    //    'End If
                    //    Dim sql As String
                    //    Dim dc As New clsData

                    //    If txt1.Text = "REMOVE WIRES" Then
                    //    Else

                    //        If txt3.Text.Length = 9 Or txt6.Text.Length = 9 Then

                    //            If txt3.Text.Length = 9 Then
                    //                sql = "INSERT INTO tblhwd"
                    //                sql = sql & "(WIRENO,REFDES1,PIN1,TERM1,REFDES2,PIN2,TERM2,OPERATION,PLAN) values "
                    //                sql = sql & "('" & txt2.Text & "','" & txt3.Text & "','" & txt4.Text & "','" & txt5.Text & "','" & txt6.Text & "','" & txt7.Text & "','" & txt8.Text & "','" & txt1.Text & "','" & txtHwd.Text & "')"
                    //            Else
                    //                sql = "INSERT INTO tblhwd"
                    //                sql = sql & "(WIRENO,REFDES1,PIN1,TERM1,REFDES2,PIN2,TERM2,OPERATION,PLAN) values "
                    //                sql = sql & "('" & txt2.Text & "','" & txt6.Text & "','" & txt7.Text & "','" & txt8.Text & "','" & txt3.Text & "','" & txt4.Text & "','" & txt5.Text & "','" & txt1.Text & "','" & txtHwd.Text & "')"

                    //            End If
                    //            dc.ExecuteSQL(sql)
                    //        End If
                    //    End If

                } while (!sr.EndOfStream);
                fillgrid(lstPartsAssy);
                XtraTabControl1.Enabled = true;
                //    Module1.Createadapter(Me.dsdrawings, "tblTemplate", ("tmpPLID ='" & Me.PlanNumber & "'"), Me.daSteps)
                daSteps.Fill(dsdrawings, "tblTemplate");
                gridSteps.Refresh();

                XtraMessageBox.Show("Import completed");

            }
        }
        private void  // ERROR: Handles clauses are not supported in C#
    btnSap_Click(object sender, System.EventArgs e)
        {

            DataRow row;
            string str;
            string str4 = null;
            int num;
            string str5 = null;
            SaveFileDialog dialog = new SaveFileDialog();
            xrParts parts = new xrParts();
            DataSet aset = new DataSet();
            clsData data = new clsData();
            DataSet set2 = new DataSet();
            DataSet dataSet = new DataSet();
            DataSet set4 = new DataSet();
            DataSet set7 = new DataSet();
            DataSet set8 = new DataSet();
            btnSap.Enabled = false;
            XtraTabControl1.Enabled = false;
            ModuleWaitDialog.newModule2.CreateWaitDialog("Please wait....", "Calculating data");
            try
            {
                aset = data.getData(string.Concat(new string[] {
          "select prtPartNumberDoc,prtDescription,prtQty,prtDwgZone,PRTECP,PRTDASH from tblAssembly where  prtPartNumberDoc ='",
          str4,
          "' and prtAction ='ADD' and  prtPlId ='",
          this.PlanNumber,
          "'"
        }));
            }
            catch (Exception ex)
            {

            }


            set7.Merge(aset);

            set4 = data.getData("SELECT PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE 1 = 2");
            aset = data.getData(("SELECT distinct PARTNUMBER FROM TBLREFDESCOMP WHERE REFCOMPPLID ='" + this.PlanNumber + "' AND REFACTION ='ADD'"));
            int num22 = (aset.Tables[0].Rows.Count - 1);
            int num10 = 0;
            while ((num10 <= num22))
            {
                str4 = Conversions.ToString(aset.Tables[0].Rows[num10][0]);

                dataSet = data.getData(string.Concat(new string[] {
          "SELECT  PARTNUMBER,DESCRIPTION,QTY,LOCATION FROM TBLREFDESCOMP WHERE REFCOMPPLID ='",
          this.PlanNumber,
          "' and partnumber ='",
          str4,
          "' and qty <> 'REF' AND REFACTION ='ADD'"
        }));
                //If str4.Contains("P5381") Then
                //Else
                //    If (dataSet.Tables.Item(0).Rows.Count > 1) Then
                //        num = 0
                //        Dim num23 As Integer = (dataSet.Tables.Item(0).Rows.Count - 1)
                //        Dim num11 As Integer = 0
                //        Do While (num11 <= num23)
                //            If (Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(2)) <> "AR") Or (Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(0)) <> "P3581-3") Then
                //                If (num11 = 0) Then
                //                    num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(2)))
                //                    str = Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(3))
                //                Else
                //                    str5 = Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(2))
                //                    num = CInt(Math.Round(CDbl((num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables.Item(0).Rows.Item(num11).Item(2)))))))
                //                    str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables.Item(0).Rows.Item(num11).Item(3))))
                //                    dataSet.Tables.Item(0).Rows.Item(num11).Delete()
                //                    dataSet.Tables.Item(0).Rows.Item(0).Item(2) = num
                //                    dataSet.Tables.Item(0).Rows.Item(0).Item(3) = str
                //                End If
                //            End If
                //            num11 += 1
                //        Loop
                //    End If


                //End If
                set4.Merge(dataSet);

                num10 += 1;
            }

            DataSet set3 = new DataSet();
            set3 = data.getData(("select distinct  prtPartNumberDoc from tblAssembly where prtPartNumberDoc not like '%P5374-%' and prtAction ='ADD' and  prtPlId ='" + this.PlanNumber + "'"));
            int num24 = (set3.Tables[0].Rows.Count - 1);
            int num12 = 0;
            while ((num12 <= num24))
            {
                str4 = Conversions.ToString(set3.Tables[0].Rows[num12][0]);
                dataSet = data.getData(string.Concat(new string[] {
          "select prtPartNumberDoc,prtDescription,prtQty,prtDwgZone,prtecp,prtdash from tblAssembly where  prtPartNumberDoc ='",
          str4,
          "' and prtAction ='ADD' and  prtPlId ='",
          this.PlanNumber,
          "'"
        }));
                str = Conversions.ToString(dataSet.Tables[0].Rows[0][3]);
                if (((dataSet.Tables[0].Rows.Count > 1) | !LikeOperator.LikeString(str, "P5374*", CompareMethod.Binary)))
                {
                    num = 0;
                    int num25 = (dataSet.Tables[0].Rows.Count - 1);
                    int num13 = 0;
                    while ((num13 <= num25))
                    {
                        if ((Conversions.ToString(dataSet.Tables[0].Rows[num13][2]) != "AR"))
                        {
                            if ((num13 == 0))
                            {
                                num = Conversions.ToInteger(Conversions.ToString(dataSet.Tables[0].Rows[num13][2]));
                                str = Conversions.ToString(dataSet.Tables[0].Rows[num13][3]);
                            }
                            else
                            {
                                str5 = Conversions.ToString(dataSet.Tables[0].Rows[num13][2]);
                                num = (int)Math.Round((double)(num + Conversions.ToDouble(Conversions.ToString(dataSet.Tables[0].Rows[num13][2]))));
                                str = Conversions.ToString(Operators.AddObject(str, Operators.ConcatenateObject(", ", dataSet.Tables[0].Rows[num13][3])));
                                dataSet.Tables[0].Rows[num13].Delete();
                                dataSet.Tables[0].Rows[0][2] = num;
                                dataSet.Tables[0].Rows[0][3] = str;
                            }
                        }
                        num13 += 1;
                    }
                }
                dataSet.Tables[0].Columns[0].ColumnName = "PARTNUMBER";
                dataSet.Tables[0].Columns[1].ColumnName = "DESCRIPTION";
                dataSet.Tables[0].Columns[2].ColumnName = "QTY";
                dataSet.Tables[0].Columns[3].ColumnName = "LOCATION";
                set4.Merge(dataSet);
                num12 += 1;
            }
            dataSet = data.getData(("select prtPartNumberDoc,prtDescription,prtQty,prtDwgZone,prtecp,prtdash from tblAssembly where prtPartNumberDoc  like '%P5374-%' and prtAction ='ADD' and  prtPlId ='" + this.PlanNumber + "'"));
            dataSet.Tables[0].Columns[0].ColumnName = "PARTNUMBER";
            dataSet.Tables[0].Columns[1].ColumnName = "DESCRIPTION";
            dataSet.Tables[0].Columns[2].ColumnName = "QTY";
            dataSet.Tables[0].Columns[3].ColumnName = "LOCATION";
            set4.Merge(dataSet);
            try
            {
                set4.Tables[0].AcceptChanges();

            }
            catch (Exception ex)
            {

            }
            isMKPL = true;
            DataSet dsf = new DataSet();
            DataSet dsf2 = new DataSet();
            string revDate = "";
            DataSet SSD = new DataSet();
            string REVNOTE = "";
            dsf.ReadXmlSchema((System.Windows.Forms.Application.StartupPath + "\\tes1.xml"));

            if (txtRev.Text != "")
            {
                SSD = data.getData("select WIRENO,PIN FROM PDFWIRES WHERE TERM ='" + this.PlanNumber + "' AND REFDES ='" + txtRev.Text + "'");
                revDate = SSD.Tables[0].Rows[0][0].ToString();
                REVNOTE = SSD.Tables[0].Rows[0][1].ToString();
            }
            dsf.Tables[0].Rows.Add(txtPartNumber.Text, txtRev.Text, txtDescription.Text, txtProgram.Text.ToUpper(), txtTeam.Text, txtPlanType.Text, revDate, REVNOTE, Module1.newModule.ECP);


            DataRow[] FOUNDROWS2;//JMR -- look at -- took Data. off Data.DataRow[]
            DataRow drt = null;//JMR -- changed DataRow drt to DataRow drt = new DataRow
            DataRow[] foundrows3;//JMR -- look at -- took Data. off Data.DataRow[]
            DataRow drt3;
            string harnessrow = "";
            int tc = 0;
            try
            {
                FOUNDROWS2 = this.dsdrawings.Tables["tblEffectivities"].Select(("EFPLID='" + this.PlanNumber + "'"));
                for (int t = 0; t <= FOUNDROWS2.Count(); t++)
                {
                    drt = FOUNDROWS2[t];

                    dsf.Tables["TVES"].Rows.Add(drt[1], drt[2], drt[3], System.DBNull.Value, System.DBNull.Value, 0);

                }


            }
            catch (Exception ex)
            {

            }

            try
            {

                FOUNDROWS2 = this.dsdrawings.Tables[0].Select(("dwgDESCRIPTION <> 'B/P' AND DwgPlId='" + this.PlanNumber + "'"));
                tc = FOUNDROWS2.Count();
                for (int t = 0; t <= FOUNDROWS2.Count() - 1; t++)
                {
                    drt = FOUNDROWS2[t];
                    dsf.Tables["DRAWINGS"].Rows.Add(drt[1], drt[3], "", drt[2], t, "0");
                    dsf.Tables["TVES"].Rows.Add(drt[4], drt[5], drt[6], t, System.DBNull.Value);

                }

                dsf.Tables["DRAWINGS"].Rows.Add(Module1.newModule.NewHarnessPTP.Substring(0, Module1.newModule.NewHarnessPTP.IndexOf("-")).ToString().Trim(), Module1.newModule.OldHarnessPTP.Substring(Module1.newModule.OldHarnessPTP.IndexOf("-") + 1).ToString().Trim(), drt[3], "HARNESS", tc, 0);
                FOUNDROWS2 = this.dsdrawings.Tables["tblEffectivities"].Select(("EFPLID='" + this.PlanNumber + "'"));
                for (int L = 0; L <= FOUNDROWS2.Count(); L++)
                {
                    drt = FOUNDROWS2[L];

                    dsf.Tables["TVES"].Rows.Add(drt[1], drt[2], drt[3], tc + 1, System.DBNull.Value);

                }

            }
            catch (Exception ex)
            {

            }
            try
            {
                FOUNDROWS2 = this.dsdrawings.Tables[5].Select(("plNotesId='" + this.PlanNumber + "'"));
                for (int t = 0; t <= FOUNDROWS2.Count(); t++)
                {
                    drt = FOUNDROWS2[t];
                    dsf.Tables["NOTES"].Rows.Add(t, drt[1], t, 0);
                    dsf.Tables["TVES"].Rows.Add(drt[3], drt[4], drt[5], t);

                }


            }
            catch (Exception ex)
            {

            }
            try
            {

                FOUNDROWS2 = dsdrawings.Tables["tblAssembly"].Select(("prtplid='" + this.PlanNumber + "'"));
                for (int t = 0; t <= FOUNDROWS2.Count(); t++)
                {

                    drt = FOUNDROWS2[t];
                    //foundrows3 = dsf.Tables("drawings").[Select]("DRAWING_NUMBER LIKE'" & drt.Item(5) & "%'")
                    //drt3 = foundrows3(0)
                    dsf.Tables["parts"].Rows.Add(drt[2], drt[3], drt[1], System.DBNull.Value, drt[5], System.DBNull.Value, t, drt[0], 0);
                    dsf.Tables["TVES"].Rows.Add(drt[8], drt[9], drt[10], System.DBNull.Value, t);

                }


            }
            catch (Exception ex)
            {

            }
            try
            {
                FOUNDROWS2 = dsdrawings.Tables[1].Select(("refcompplid='" + this.PlanNumber + "'"));
                for (int t = 0; t <= FOUNDROWS2.Count(); t++)
                {
                    drt = FOUNDROWS2[t];
                    dsf.Tables["parts"].Rows.Add(drt[1], drt[2], drt[3], drt[4], drt[5], tc);
                }


            }
            catch (Exception ex)
            {

            }
            try
            {
                FOUNDROWS2 = set7.Tables[0].Select(("WIRENUMBER <> ''"));
                for (int t = 0; t <= FOUNDROWS2.Count(); t++)
                {
                    drt = FOUNDROWS2[t];



                    if (drt[0].ToString().Contains("SH") | drt[0].ToString().EndsWith("-2") | drt[0].ToString().EndsWith("-3") | drt[0].ToString().EndsWith("-4") | drt[0].ToString().EndsWith("-5"))
                    {
                        drt[1] = "";
                        drt[2] = "9992";
                    }
                    dsf.Tables["wires"].Rows.Add(drt[0], drt[3], drt[1], Conversions.ToInteger(drt[2]), System.DBNull.Value, "ADD", tc);//JMR -- look at -- changed Int to Conversions.ToInteger
                }


            }
            catch (Exception ex)
            {

            }

            SaveFileDialog Sdialog = new SaveFileDialog { Filter = "xml files (*.xml)|*.xml" };
            if ((Sdialog.ShowDialog() == DialogResult.OK))
            {
                string fileName = Sdialog.FileName;

                dsf.WriteXml(fileName);
            }

            // SapExportToExcel(set4.Tables(0), set7.Tables(0), set9.Tables(0))
            btnSap.Enabled = true;
            XtraTabControl1.Enabled = true;
            ModuleWaitDialog.newModule2.CloseWaitDialog();
            //parts.LabelControl1.Text = ("MKPL FOR " & Me.txtDescription.Text)
            //parts.GridControl1.DataSource = set4.Tables.Item(0)
            //parts.LabelControl1.Text = String.Concat(New String() {"MKPL for ", Me.NEWHARNESSPTP.Substring(0, Me.NEWHARNESSPTP.IndexOf("-")), " from ", Me.OLDHARNESSPTP.Substring(Me.OLDHARNESSPTP.IndexOf("-")), " to ", Me.NEWHARNESSPTP.Substring(Me.NEWHARNESSPTP.IndexOf("-")), " ( LWA ", Me.NEWHARNESSPTP.Substring(0, Me.NEWHARNESSPTP.IndexOf("-")), "-", Me.txtTbd.Text, ")"})
            //parts.ShowPreview()

        }
        private void SapExportToExcel(System.Data.DataTable objDT, System.Data.DataTable objDT2, System.Data.DataTable objDT3)
        {
            //object Excel = CreateObject("Excel.Application");
            //object Excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));//JMR -- replaced above line 'quick and dirty way'//second attempt
            Microsoft.Office.Interop.Excel._Application Excel = new Microsoft.Office.Interop.Excel.Application();//JMR -- third attempt


            System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");



            string strFilename = "";//JMR -- nulled it
            int intCol;
            int intRow;
            string strPath = "c:\\";
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = "Desktop";

            DataView DFG = new DataView();
            if (isMKPL)
            {

            }
            else if (IsElectrical)
            {
                objDT2.DefaultView.Sort = "bacBraid ASC";
                objDT2.AcceptChanges();
                dlg.FileName = Module1.newModule.NewHarnessPTP.Substring(4, Module1.newModule.NewHarnessPTP.IndexOf("-") - 4) + " ELECTRICAL PLANNING";
                dlg.CheckFileExists = false;
                DFG = new DataView(objDT2);
                DFG.Sort = "bacBraid asc,[WIRE NUMBER]";

            }
            if (isMKPL)
            {
                dlg.FileName = Module1.newModule.NewHarnessPTP + " SAP_EXPORT";
                dlg.CheckFileExists = false;
            }
            dlg.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx|(Save as xls for Office 2003)|*.xls|(Save as xml File for Sap)|*.xml|All files (*.*)|*.*";

            if (Excel == null)
            {
                //MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical);
                XtraMessageBox.Show("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", "ERROR");//JMR -- look at -- changed above line to this line
                return;
            }
            try
            {
                // ERROR: Not supported in C#: WithStatement
                try
                {
                    Excel.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\eplansys.pln");
                }
                catch(Exception ex)
                {
                    //'      XtraMessageBox.Show(ex.Message)
                    Excel.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\eplansys2.pln");
                }

                if(IsElectrical)
                {
                    Excel.Worksheets[4].Select();
                }
                Excel.Cells[1, 1].EntireRow.Font.Bold = true;
                Excel.Cells[1, 1].EntireRow.Font.Size = 13;
                Excel.Cells[1, 1].Interior.color = Color.FromArgb(196, 215, 155);

                int intK = 1;
                int intI = 1;
                string ass1 = "";
                string ass2 = "";
                clsData data = new clsData();
                DataSet SETASS = new DataSet();
                SETASS = data.getData(("select distinct  PRTDash from tblAssembly where prtAction ='ADD' and  prtPlId ='" + this.PlanNumber + "' order by prtdash"));
                int num24a = (SETASS.Tables[0].Rows.Count - 1);
                int num12a = 0;
                int intr = 4;
                int inth = 4;
                do{ 
                    intI = intr;

                    ass1 = SETASS.Tables[0].Rows[num12a][0].ToString();
                    DataRow[] FOUNDROWS = null;

                    FOUNDROWS = objDT.Select(("prtdash ='" + ass1 + "'"));

                    if(FOUNDROWS.Count() != 0) 
                    {
                        if(num12a == 0) 
                        {
                            Excel.Cells[(inth), 7].Value = FOUNDROWS[0].ItemArray[4] + "-" + ass1;
                            inth += 1;
                        }else
                        {
                            Excel.Cells[(inth), 7].Value = FOUNDROWS[0].ItemArray[4] + "-" + ass1;
                            inth += 1;
                        }

                        inth = (inth + FOUNDROWS.Count());


                        ass2 = SETASS.Tables[0].Rows[num12a][0].ToString();
                        int num14 = (FOUNDROWS.Count() - 1);
                        int i = 0;
                        
                        do{
                            for(intCol = 0; intCol <= 4; intCol++)
                            {
                                intI = (inth - FOUNDROWS.Count());

                                for(intRow = 0; intRow <= FOUNDROWS.Count() - 1; intRow++)
                                {
                                    if(intRow == 0)
                                    {
                                        if(intCol == 0)
                                        {
                                            Excel.Cells[intI, 8].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 1)
                                        {
                                            Excel.Cells[intI, 10].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 2)
                                        {
                                            Excel.Cells[intI, 9].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 3)
                                        {
                                            //'.Cells(intI, 7).Value = FOUNDROWS(intRow).ItemArray(intCol)
                                        }
                                    }else
                                    {
                                        if(intCol == 0)
                                        {
                                            Excel.Cells[intI, 8].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 1)
                                        {
                                            Excel.Cells[intI, 10].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 2)
                                        {
                                            Excel.Cells[intI, 9].Value = FOUNDROWS[intRow].ItemArray[intCol];
                                        }else if(intCol == 3)
                                        {
                                            //' .Cells(intI, 7).Value = FOUNDROWS(intRow).ItemArray(intCol)
                                        }
                                        //'ElseIf intCol = 4 Then
                                        //'    .Cells(intI, 7).Value = objDT.Rows(intRow).ItemArray(intCol)
                                    }
                                    intI += 1;
                                }
                                intK += 1;
                            }
                            i += 1;
                            intr += 1;
                        }while(i <= num14);
                    }
                    num12a += 1;
                }while(num12a <= num24a);



                //'.cells(1, 1).value = "Heading" 'Heading of the excel file

                //'For intCol = 0 To objDT.Columns.Count - 1
                //'    .cells(3, intI).value = objDT.Columns(intCol).ColumnName
                //'    .cells(3, intI).EntireRow.Font.Bold = True
                //'    .cells(3, intI).EntireRow.Font.Size = 12
                //'    .cells(3, intI).Interior.color = RGB(191, 191, 191)
                //'    intI += 1
                //'Next
                //'intI = 4


                if(IsElectrical)
                {
                    try
                    {
                        Excel.Cells[objDT.Rows.Count + 5, 1].value = "BRAID : SINGLE TRACE";
                    }
                    catch(Exception ex)
                    {
                        Excel.Cells[objDT.Rows.Count + 5, 1].value = "BRAID : SINGLE TRACE";
                    }
                    Excel.Cells[objDT.Rows.Count + 5, 1].EntireRow.Font.Bold = true;
                    Excel.Cells[objDT.Rows.Count + 5, 1].EntireRow.Font.Size = 13;
                    Excel.Cells[objDT.Rows.Count + 5, 1].Interior.color = Color.FromArgb(196, 215, 155);
                }

                if(isMKPL)
                {
                    isMKPL = true;
                    //'Try
                    //'    .cells(objDT.Rows.Count + 5, 1).value = "WIRES"
                    //'Catch ex As Exception
                    //'    .cells(objDT.Rows.Count + 5, 1).value = "WIRES"
                    //'End Try
                    //'.cells(objDT.Rows.Count + 5, 1).EntireRow.Font.Bold = True
                    //'.cells(objDT.Rows.Count + 5, 1).EntireRow.Font.Size = 13
                    //'.cells(objDT.Rows.Count + 5, 1).Interior.color = RGB(196, 215, 155)
                    Excel.Cells[2, 6].value = this.txtPartNumber.Text.Trim();
                    intI = 1;
                    //'For intCol = 0 To objDT2.Columns.Count - 1
                    //'    .cells(objDT.Rows.Count + 7, intI).value = objDT2.Columns(intCol).ColumnName
                    //'    .cells(objDT.Rows.Count + 7, intI).EntireRow.Font.Bold = True
                    //'    .cells(objDT.Rows.Count + 7, intI).EntireRow.Font.size = 12
                    //'    .cells(objDT.Rows.Count + 7, intI).Interior.color = RGB(191, 191, 191)
                    //'    intI += 1
                    //'Next
                    //'.cells(objDT.Rows.Count + objDT2.Rows.Count + 9, intI).EntireRow.Font.Size = 10

                    intK = 1;
                    for(intCol = 0; intCol <= objDT2.Columns.Count - 1; intCol++)
                    {
                        intI = objDT.Rows.Count + 8;
                        for(intRow = 0; intRow <= objDT2.Rows.Count - 1; intRow++)
                        {
                            if(intCol == 0)
                            {
                                Excel.Cells[intI, 6].Value = objDT2.Rows[intRow].ItemArray[intCol];
                            }else if(intCol == 1)
                            {
                                Excel.Cells[intI, 8].Value = objDT2.Rows[intRow].ItemArray[intCol];
                            }else if(intCol == 2)
                            {
                                Excel.Cells[intI, 7].Value = objDT2.Rows[intRow].ItemArray[intCol];
                                Excel.Cells[intI, 11].Value = "1";
                            }
                            intI += 1;
                        }
                        intK += 1;
                    }
                }
                if(IsElectrical)
                {
                    IsElectrical = false;
                    intI = 1;
                    for(intCol = 1; intCol <= DFG.Table.Columns.Count - 1; intCol++)
                    {
                        Excel.Cells[objDT.Rows.Count + 7, intI].value = DFG.Table.Columns[intCol].ColumnName;
                        Excel.Cells[objDT.Rows.Count + 7, intI].EntireRow.Font.Bold = true;
                        Excel.Cells[objDT.Rows.Count + 7, intI].EntireRow.Font.size = 12;
                        Excel.Cells[objDT.Rows.Count + 7, intI].Interior.color = Color.FromArgb(191, 191, 191);
                        intI += 1;
                    }
                    //'.cells(objDT.Rows.Count + objDT2.Rows.Count + 9, intI).EntireRow.Font.Size = 10

                    intK = 1;
                    for(intCol = 1; intCol <= DFG.Table.Columns.Count - 1; intCol++)
                    {
                        intI = objDT.Rows.Count + 8;
                        objDT2.DefaultView.Sort = "bacBraid ASC,[WIRE NUMBER]";
                        string bacfg = "@#";
                        string bacfg2 = "@#2";

                        foreach (DataRowView introwd in objDT2.DefaultView)
                        {
                            bacfg = introwd["bacBraid"].ToString();
                            if(bacfg != bacfg2)
                            {
                                Excel.Cells[intI, 1].Value = introwd["bacBraid"];
                                for(int ht = 1; ht <= 5; ht++)
                                {
                                    Excel.Cells[intI, ht].EntireRow.Font.Bold = true;
                                    Excel.Cells[intI, ht].EntireRow.Font.size = 12;
                                    Excel.Cells[intI, ht].Interior.color = Color.FromArgb(217, 217, 217);

                                }

                                intI += 1;

                            }



                            Excel.Cells[intI, intK].Value = introwd[intK];

                            intI += 1;
                            bacfg2 = bacfg;
                        }

                        intK += 1;

                    }
                }

                if(Module1.newModule.electrical == true)
                {

                    Module1.newModule.electrical = false;
                    try
                    {
                        Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 9, 1].value = "BRAID: NO BRAID";
                    }catch(Exception ex)
                    {
                        //'  .cells(objDT.Rows.Count + 5, 1).value = "MANUFACTURING INSTRUCTIONS FOR LWA Wxxxxx"
                    }
                    Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 9, 1].EntireRow.Font.Bold = true;
                    Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 9, 1].EntireRow.Font.Size = 13;
                    Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 9, 1].Interior.color = Color.FromArgb(196, 215, 155);
                    intI = 1;
                    for(intCol = 0; intCol <= objDT3.Columns.Count - 1; intCol++)
                    {
                        Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 11, intI].value = objDT3.Columns[intCol].ColumnName;
                        Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 11, intI].EntireRow.Font.Bold = true;
                        Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 11, intI].EntireRow.Font.Size = 12;
                        Excel.Cells[objDT.Rows.Count + objDT2.Rows.Count + 11, intI].Interior.color = Color.FromArgb(191, 191, 191);
                        //' .cells(objDT.Rows.Count + objDT2.Rows.Count + 7, intI).fillcolor = Color.Beige

                        intI += 1;
                    }

                    intK = 1;
                    for(intCol = 0; intCol <= objDT3.Columns.Count - 1; intCol++)
                    {
                        intI = objDT.Rows.Count + objDT2.Rows.Count + 12;
                        for(intRow = 0; intRow <= objDT3.Rows.Count - 1; intRow++)
                        {
                            Excel.Cells[intI, intK].Value = objDT3.Rows[intRow].ItemArray[intCol];

                            intI += 1;
                        }
                        intK += 1;
                    }

                }
                //'.CELLS(1, 1).WIDTH = 34

                //if(Mid$(strPath, strPath.Length, 1) <> "\\")
                if(strPath.Substring(strPath.Length - 1, 1) != "\\")
                {
                    strPath = strPath + "\\";
                }
                dlg.OverwritePrompt = false;
                ModuleWaitDialog.newModule2.CloseWaitDialog();
                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    if(dlg.FilterIndex == 3)
                    {
                        DataSet SAPXML = new DataSet();
                        SAPXML.Tables.Add("PARTS");
                        SAPXML.Tables.Add("WIRES");
                        SAPXML.Tables["PARTS"].Merge(objDT);
                        SAPXML.Tables["WIRES"].Merge(objDT2);
                        SAPXML.WriteXml(dlg.FileName);
                        ModuleWaitDialog.newModule2.CloseWaitDialog();
                        MessageBox.Show("File saved as : " + System.Environment.NewLine + dlg.FileName);
                        return;

                    }
                    strFilename = dlg.FileName;
                    //'strFilename = strPath & "Excel2.xlsx"
                    Excel.ActiveCell.Worksheet.SaveAs(strFilename);
                    Excel.Workbooks.Open(strFilename);
                    Excel.Visible = true;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel);
                }

                Excel = null;
                // MsgBox("Data's are exported to Excel Succesfully in '" & strFilename & "'", MsgBoxStyle.Information)
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Cannot access "))
                {
                    strFilename = ((strFilename.Substring(0, (strFilename.Length - 5))) + "new.xlsx");
                    Excel.ActiveCell.Worksheet.SaveAs(strFilename);
                    Excel.Workbooks.Open(strFilename);
                    Excel.Visible = true;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel);
                    //MsgBox("File saved as " + strFilename);
                    XtraMessageBox.Show("File save as " + strFilename);//JMR -- look at -- changed above line to this line
                }
                else
                {

                    //MsgBox(ex.Message);
                    XtraMessageBox.Show(ex.Message);//JMR -- look at -- changed above line to this line
                }


            }
            // The excel is created and opened for insert value. We most close this excel using this system

            System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
        }

        private void gridGeneral_Click(object sender, EventArgs e)
        {

        }

        public frmOps()
        {
            InitializeComponent();
        }
    }
}

